Module:Item

local getArgs = require('Module:Arguments').getArgs local p = {}

function p.main(frame) local args = getArgs(frame) return p._main(args) end

function p._main(args) local item = args[1] local itemname = args[1] or '???' local rarity = args["rarity"] or '' local sell = args["sell"] or '' local drop = args["drop"] or '' local lost = args["lost"] or '' local locations = args["locations"] or '???' local param2 = args[2] or '' local param3 = args[3] or '' local param4 = args[4] or '' local param5 = args[5] or ''

local row = mw.html.create -- Create base for all rows local attrrow1 = mw.html.create -- Create base attributes row local attrrow2 = mw.html.create -- Create main attributes row local paramcell = mw.html.create -- Create node for optional parameters locspan = 2 --Colspan of the Locations row. Default Is 2 and Increases for each param[#] cell paramspan = 1 --Rowspan of each param[#] cell for when one of the attribue parameters Is used

if param2 ~=  or param3 ~=  or param4 ~=  or param5 ~=  then elseif param2 ~= '' and param3 ~= 'summary' then paramcell :tag('td'):wikitext(param2):attr('rowspan', paramspan) :done --back to tr     locspan = 3 elseif param2 ~= '' and param3 == 'summary' then paramcell :tag('td'):wikitext(param2):attr('colspan', '2'):attr('rowspan', paramspan) :done locspan = 4

elseif param3 ~= '' and param3 ~= 'summary' then paramcell :tag('td'):wikitext(param3):attr('rowspan', paramspan) :done locspan = 4 elseif param3 == 'summary' then locspan = 5 elseif param4 ~= '' then paramcell :tag('td'):wikitext(param4):attr('rowspan', paramspan) :done --back to tr     locspan = 6 elseif param5 ~= '' then paramcell :tag('td'):wikitext(param3):attr('rowspan', paramspan) :done --back to tr     locspan = 7 end

if rarity ~=  or sell ~=  or drop ~=  or lost ~=  then paramspan = 2 --Rowspan of each param[#] cell attrrow1 :tag('tr'):css( 'background-color', '#'..mw.getCurrentFrame:expandTemplate { title = 'TableColor/cell'} ) --Base attribues row :tag('td'):css('white-space', 'nowrap'):css('line-height', '1.2em'):attr('colspan', '2') -- Base attributes cell :tag('table') --Attributes table :node(attrrow2) if rarity ~= '' then attrrow2 :tag('tr') :tag('td'):wikitext(' Rarity: ', rarity ,' ') -- Rarity :done :done end

if sell ~= '' then attrrow2 :tag('tr') :tag('td'):wikitext(' Sell Price: ', sell ,' ') -- Sell price :done :done end

if drop == 'no' then attrrow2 :tag('tr') :tag('td'):wikitext(' Cannot be dropped. ') -- Dropability :done :done end

if lost == 'no' then attrrow2 :tag('tr') :tag('td'):wikitext(' Cannot be lost. ') -- Losability :done :done end end

row:tag('tr'):css( 'background-color', '#'..mw.getCurrentFrame:expandTemplate { title = 'TableColor/cell'} ) --IS and Item row :tag('td'):wikitext(mw.getCurrentFrame:expandTemplate { title = 'IS', args={ item } }) --IS cell :done --finish td     :tag('td'):wikitext(' ', itemname ,' ') --Item name cell :done --finish td     :node(paramcell) :node(attrrow1) --base attributes row :done :tag('tr'):css( 'background-color', '#'..mw.getCurrentFrame:expandTemplate { title = 'TableColor/cell'} )--Locations row :tag('td'):wikitext('Locations\n\n', locations):attr('colspan', locspan) :done

return tostring(row)

end

return p

-- Copy and paste for the console <:) print(p.main)