Module:Characters

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

function p.List( frame ) local args = frame.args local fieldstable = { "Name", "Image", "Alignment", "Minion", "Boss", "Lore", "Dialogue", "Function", "Race", "Locations", "BaseHealth", "Skills", "Equipment", "_pageName", }   local tables = 'Characters' 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("Image"):done end if args.Name ~= "hide" then tbl:tag("th"):wikitext("Name"):done end if args.Types ~= "hide" then tbl:tag("th"):wikitext("Types"):done end if args.Locations ~= "hide" then tbl:tag("th"):wikitext("Locations"):done end if args.Skills ~= "hide" then tbl:tag("th"):wikitext("Skills"):done end if args.Equipment== "show" then tbl:tag("th"):wikitext("Equipment"):done end if args.Race == "show" then tbl:tag("th"):wikitext("Race"):done end if args.Function == "show" then tbl:tag("th"):wikitext("Function"):done end if args.BaseHealth == "show" then tbl:tag("th"):wikitext("Base Health"):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.Types ~= "hide" then tr:tag("td"):wikitext( row.Alignment .. (row.Minion =='1' and ' Minion' or '') .. (row.Boss == '1' and ' Boss' or '') .. (row.Dialogue == '1' and ' Has Dialogue' or '') .. (row.Lore == '1' and ' Found in Lore' or '') ):done end if args.Locations ~= "hide" then tr:tag("td"):wikitext( mw.text.listToText( mw.text.split( row.Locations, ',' ) ) ):done end if args.Skills ~= "hide" then tr:tag("td"):wikitext( mw.text.listToText( mw.text.split( row.Skills, ',' ) ) ):done end if args.Equipment == "show" then tr:tag("td"):wikitext( mw.text.listToText( mw.text.split( row.Equipment, ',' ) ) ):done end if args.Race == "show" then tr:tag("td"):wikitext( row.Race ):done end if args.Function == "show" then tr:tag("td"):wikitext( row.Function ):done end if args.BaseHealth == "show" then tr:tag("td"):wikitext(row.BaseHealth):done end end return tbl end -- . . . end return p