Module:Quests

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

function p.List( frame ) local args = frame.args local fieldstable = { "Quests.Name=Name", "Quests.StartLocation=StartLocation", "Quests.Experience=XP", "Quests.PassivePoints=PassivePoints", "Quests.Gold=Gold", "Quests.Type=Type", "Quests.QuestGiver=QuestGiver", "Quests.OtherRewards=OtherRewards", "Quests.Prereqs=Prereqs", "Quests.Unlocks=Unlocks", "Quests._pageName=QuestPage", "Locations.Name=lName", "Locations.Level=Level", }   local tables = 'Quests, Locations' 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, join='Quests.StartLocation=Locations.Name', orderBy='Locations.Level' }   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.Name ~= "hide" then tbl:tag("th"):wikitext("Name"):done end if args.Type ~= "hide" then tbl:tag("th"):wikitext("Type"):done end if args.Location ~= "hide" then tbl:tag("th"):wikitext("Location"):done end if args.Level ~= "hide" then tbl:tag("th"):wikitext("Level"):done end if args.PassivePoints ~= "hide" then tbl:tag("th"):wikitext("Passive Points"):done end if args.Experience ~= "hide" then tbl:tag("th"):wikitext("XP"):done end if args.Gold ~= "hide" then tbl:tag("th"):wikitext("Gold"):done end if args.OtherRewards ~= "hide" then tbl:tag("th"):wikitext("Rewards"):done end if args.QuestGiver == "show" then tbl:tag("th"):wikitext("Class"):done end tbl:done --Construct the rows in the table for _,row in ipairs(result) do		tr = tbl:tag("tr") if args.Name ~= "hide" then tr:tag("td"):wikitext("" .. row.Name .. ""):done end if args.Type ~= "hide" then tr:tag("td"):wikitext(row.Type):done end if args.Location ~= "hide" then tr:tag("td"):wikitext(row.lName):done end if args.Level ~= "hide" then tr:tag("td"):wikitext(row.Level):done end if args.PassivePoints ~= "hide" then tr:tag("td"):wikitext(row.PassivePoints):done end if args.Experience ~= "shide" then tr:tag("td"):wikitext(row.XP):done end if args.Gold ~= "hide" then tr:tag("td"):wikitext(row.Gold):done end if args.OtherRewards ~= "hide" then tr:tag("td"):wikitext(row.OtherRewards):done end if args.QuestGiver == "show" then tr:tag("td"):wikitext(row.QuestGiver):done end end return tbl end -- . . . end return p