Module:Locations

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

function p.List( frame ) local args = frame.args local fieldstable = { "Name", "Image", "Type", "Region", "Place", "Landmarks", "Eras", "ConnectedZones", "IsTown", "Level", "Year", "_pageName" }   local tables = '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 } 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.Image ~= "hide" then tbl:tag("th"):wikitext("Mini-Map"):done end if args.Name ~= "hide" then tbl:tag("th"):wikitext("Name"):done end if args.Type == "show" then tbl:tag("th"):wikitext("Type"):done end if args.Region ~= "hide" then tbl:tag("th"):wikitext("Region"):done end if args.Eras ~= "hide" then tbl:tag("th"):wikitext("Eras"):done end if args.Year ~= "hide" then tbl:tag("th"):wikitext("Year"):done end if args.Level ~= "hide" then tbl:tag("th"):wikitext("Level"):done end if args.Landmarks ~= "hide" then tbl:tag("th"):wikitext("Landmarks"):done end if args.ConnectedZones ~= "hide" then tbl:tag("th"):wikitext("ConnectedZones"):done end if args.IsTown ~= "hide" then tbl:tag("th"):wikitext("Town"):done end tbl:done --Construct the rows in the table for _,row in ipairs(result) do		tr = tbl:tag("tr") if args.Image ~= "hide" then tr:tag("td"):wikitext((row.Image ~=  and  or '')):done end if args.Name ~= "hide" then tr:tag("td"):wikitext( .. row.Name .. ):done end if args.Type == "show" then tr:tag("td"):wikitext(row.Type):done end if args.Region ~= "hide" then tr:tag("td"):wikitext(row.Region):done end if args.Eras ~= "hide" then tr:tag("td"):wikitext( mw.text.listToText( {row.Era, (row.Era2 ~=  and row.Era2 or nil) , (row.Era3 ~=  and row.Era3 or nil) , (row.Era4 ~= '' and row.Era4 or nil) } ) ):done end if args.Year ~= "hide" then tr:tag("td"):wikitext(row.Year):done end if args.Level ~= "hide" then tr:tag("td"):wikitext(row.Level):done end if args.Landmarks ~= "hide" then tr:tag("td"):wikitext(mw.text.listToText( mw.text.split( row.Landmarks, ',' ) )):done end if args.ConnectedZones ~= "hide" then tr:tag("td"):wikitext( mw.text.listToText( mw.text.split( row.ConnectedZones, ',' ) ) ):done end if args.IsTown ~= "hide" then tr:tag("td"):wikitext( (row.IsTown == '1' and 'Yes' or '') ):done end end return tbl end -- . . . end return p