Module:Buildings

local p = {} p.buildings = mw.loadData('Module:Buildings/data') local f = require('Module:Functions')

function getImages(data, levels, description, name, frame) local images = {'")	return frame:preprocess(table.concat(images, "\n")) end

function getCharacters(data) local characters = "" if(data == nil) then return nil end for i, j in pairs(data) do		characters = characters..j	end return characters end

function p.table(frame) local data = { '==Buildings List==', ' '   }    for a, s in pairs(p.buildings) do    	table.insert(data,'{| class="wikitable mw-datatable sortable" style="text-align: center;"') table.insert(data,'|-') table.insert(data, '| '..getImages(s.images,s.levels, s.description,a, frame)) table.insert(data, '|-') table.insert(data, '| style="padding:0;"|') table.insert(data, '{| class="wikitable mw-datatable mw-collapsible mw-collapsed" style="text-align: center; width:100%; height:100%; padding:0; margin:0;"') table.insert(data, '|-') table.insert(data, '! colspan=5 | Stats') table.insert(data, '|-') table.insert(data, '| colspan=5 | Base') table.insert(data, '|-') table.insert(data, '|'..s.stats.money[1]) -- This definitely needs cleaning up		table.insert(data, '|'..s.stats.xp[1])   -- And this table.insert(data, '|'..f.time(s.stats.time)) table.insert(data, '| colspan=2|'..s.stats.unlock) table.insert(data, '|-') for i, j in pairs(s.tasks) do   		table.insert(data, '| colspan=5 |'..i)    		table.insert(data, '|-') table.insert(data, '|'..j.money) table.insert(data, '|'..j.xp) table.insert(data, '|'..f.time(j.time)) if(getCharacters(j.characters) == nil) then table.insert(data, '| colspan=2|'..j.unlock) else table.insert(data, '|'..j.unlock) table.insert(data, '|'..getCharacters(j.characters)) end table.insert(data, '|-') end table.insert(data, '|}') table.insert(data, '|-') table.insert(data, '|}') end table.insert(data, 'Add building ') return table.concat(data, "\n") end

return p