Module:Equipment

local p = {} local cargo = mw.ext.cargo

function p.List( frame ) local args = frame if frame == mw.getCurrentFrame then args = frame.args else frame = mw.getCurrentFrame end local fieldstable = { "ItemIcon", "ItemName", "ItemType", "BaseType", "Rarity", "ItemBase", "LevelReq", "ImplicitType", "ImplicitAmount", "SecondImplicitType", "SecondImplicitAmount", "ThirdImplicitType", "ThirdImplicitAmount", "WeaponRange", "affix1", "affix2", "affix3", "affix4", "SetMod1", "SetMod2", "SetName", "flavortext", "Sellprice", "_pageName", }   local tables = 'Equipment' local fields = table.concat(fieldstable,",") -- optional parameters are grouped in one table -- you can omit any or all of them, except joinOn if you use more than one table local cargoquery = { where = args.where } local result = mw.ext.cargo.query( tables, fields, cargoquery )

if result[1] == nil then return args.default

elseif result[1] ~= nil then --Start the table local tbl = mw.html.create('table') tbl:addClass('wikitable sortable mw-datatable') if args.ItemIcon ~= "hide" then tbl:tag("th"):wikitext("Icon"):done end if args.ItemName ~= "hide" then tbl:tag("th"):wikitext("Name"):done end if args.SetName == "show" then tbl:tag("th"):wikitext("Set"):done end if args.ItemType~= "hide" then tbl:tag("th"):wikitext("Type"):done end if args.Implicits ~= "hide" then tbl:tag("th"):wikitext("Implicits"):done end if args.Rarity ~= "hide" then tbl:tag("th"):wikitext("Rarity"):done end if args.Affixes == "show" then tbl:tag("th"):wikitext("Unique Effects"):done end if args.SetMods == "show" then tbl:tag("th"):wikitext("Set Modifiers"):done end if args.FlavorText == "show" then tbl:tag("th"):wikitext("Flavor Text"):done end if args.ItemBase == "show" then tbl:tag("th"):wikitext("Base Item"):done end if args.SellPrice == "show" then tbl:tag("th"):wikitext("Sell Price"):done end if args.LevelReq ~= "hide" then tbl:tag("th"):wikitext("Req. Level"):done end tbl:done --Construct the rows in the table for _,row in ipairs(result) do		tr = tbl:tag("tr") if args.ItemIcon ~= "hide" then tr:tag("td"):wikitext(""):done end if args.ItemName ~= "hide" then tr:tag("td"):wikitext("" .. row.ItemName .. ""):done end if args.SetName == "show" then tr:tag("td"):wikitext(row.SetName):done end if args.ItemType ~= "hide" then tr:tag("td"):wikitext(row.ItemType .. (row.BaseType ~=  and ' -  ' or ) .. (row.BaseType or '') ):done end if args.Implicits ~= "hide" then tr:tag("td"):wikitext( row.ImplicitAmount .. ' ' .. row.ImplicitType .. (row.SecondImplicitAmount ~= '' and row.SecondImplicitAmount and ' ' or ) .. (row.SecondImplicitAmount or ) .. (row.SecondImplicitType ~=  and ' ' or ) .. row.SecondImplicitType .. (row.ThirdImplicitAmount ~= '' and row.ThirdImplicitAmount and ' ' or ) .. (row.ThirdImplicitAmount or ) .. (row.ThirdImplicitType ~=  and ' ' or ) .. row.ThirdImplicitType .. (row.WeaponRange ~= '' and row.WeaponRange and ' Weapon Range: ' or ) .. (row.WeaponRange or ) .. (row.WeaponRange ~=  and row.WeaponRange and 'm' or ) ):done end if args.Rarity ~= "hide" then tr:tag("td"):wikitext(row.Rarity):done end if args.Affixes == "show" then tr:tag("td"):wikitext( row.affix1 .. (row.affix2 ~= '' and ' ' or ) .. (row.affix2 or ) .. (row.affix3 ~= '' and ' ' or ) .. (row.affix3 or ) .. (row.affix4 ~= '' and ' ' or ) .. (row.affix4 or ) ):done end if args.SetMods == "show" then tr:tag("td"):wikitext( (row.SetMod1 ~= '' and 'Set (2): ' or ) .. row.SetMod1 .. (row.SetMod2 ~=  and ' Set (3): ' or ) .. (row.SetMod2 or ) ):done end if args.FlavorText == "show" then tr:tag("td"):wikitext(row.flavortext):done end if args.ItemBase == "show" then tr:tag("td"):wikitext( (row.ItemBase ~=  and  or ) .. (row.ItemBase or ) .. (row.ItemBase ~=  and  or '') ):done end if args.SellPrice == "show" then tr:tag("td"):wikitext(row.Sellprice):done end if args.LevelReq ~= "hide" then tr:tag("td"):wikitext(row.LevelReq):done end end return tbl end -- . . . end return p