Module:Decorations

local p = {} p.deco = mw.loadData('Module:Decorations/data') p.config = { color = { flowers = "#9ee89e", decor = "#a9d3eb", trees = "#d6b792", other = "#f29dde" },	starsMin = 0.5, starsMax = 3, starsStep = 0.5 } local f = require('Module:Functions')

function benefit(value) stars = "" local val = value if(val ~= math.floor(val)) then stars = "" end val = math.floor(val) while val>0 do		stars = ""..stars val = val-1 end return stars end

function costType(type) if(string.match("kiss",type)) then return "" end if(string.match("money",type)) then return "" end return " "..type end

function decos(j) local data = "" color = p.config.color[j.type] if(j.other ~= nil) then color = p.config.color.other end data = data..' '..j.name.." "..j.cost..costType(j.costType).." " return data end function p.table local data = {} for i, j in pairs(p.config.color) do		table.insert(data, ' '..f.upfirst(i)..' ') end table.insert(data,' ') table.insert(data,'{| class="wikitable mw-datatable" style="text-align: center;"') table.insert(data,'|-') local stars = { unknown = {}, }	for i in f.range(p.config.starsMin,p.config.starsMax,p.config.starsStep) do table.insert(data,"! "..benefit(i)) stars[i] = {} end table.insert(data,'! Unknown') table.insert(data,'|-') for i, j in pairs(p.deco) do		star = j.benefit if (star == nil or type(star) ~= "number") then table.insert(stars["unknown"], '|'..decos(j)) else table.insert(stars[j.benefit], '|'..decos(j)) end end for i in f.range(p.config.starsMin,p.config.starsMax,p.config.starsStep) do		table.insert(data, '|'..table.concat(stars[i],"\n")) end table.insert(data, '|'..table.concat(stars["unknown"],"\n")) table.insert(data, '|-') table.insert(data, '|}') table.insert(data, ' ') return table.concat(data,"\n") end

function empty(what) if what ~= nil then return what end return "" end function p.stats --{type="", name="", cost=0, costType="money", benefit=0, space=0, playerLvl = nil, other = nil}, local data = { ' ',		'{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',		'! Type', '! Name', '! Cost', '! Cost Type', '! Benefit', '! Space', '! Player LvL', '! Other', '|-'	}	for i, j in pairs(p.deco) do		table.insert(data, '|'..f.upfirst(empty(j.type))) table.insert(data, '|'..empty(j.name)) table.insert(data, '|'..empty(j.cost)) table.insert(data, '|'..costType(empty(j.costType))) table.insert(data, '|'..empty(j.benefit)) table.insert(data, '|'..empty(j.space)) table.insert(data, '|'..empty(j.playerLvl)) table.insert(data, '|'..empty(j.other)) end table.insert(data, '|}') table.insert(data, ' ') return table.concat(data,"\n") end

function p.seeds local data = {} return table.concat(data,"\n") end

return p