Last Epoch Wiki
Advertisement

This module is used to display Cargo Queries of the table created in Template:Builds

Args[]

  • where= used to define the WHERE of a cargo query. Uses properties of SQL WHERE.
  • default= defines what to display if there are no results from the query.
  • fieldname=show/hide defines whether to show or hide a given field in the table display

Fieldnames used in table display[]

default shown[]

  • Name
  • Class
  • LastVersion
  • Author

default hidden[]

  • Skills

Usage[]

{{#invoke: Builds|List|where=Field="Thing"|default=no results here, buddy|LastVersion=hide|Skills=show}}


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

function p.List( frame )
    local args = frame.args
    local fieldstable = {
	"Name",
	"Class",
	"Author",
	"Skills",
        "SkillNodes",
        "Shards",
        "LastVersion",
	"SearchTags",
        "Weapon",
        "Offhand",
        "BodyArmor",
        "Amulet",
        "Helmet",
        "Belt",
        "Ring1",
        "Ring2",
        "Relic",
        "Gloves",
        "Boots",
        "_pageName",
		}
    local tables = 'Builds'
    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 , groupBy = "_pageName" , orderBy = args.orderby}
    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("Build Name"):done()
                      end
                      if args.Class ~= "hide" then
			tbl:tag("th"):wikitext("Class"):done()
                      end
                      if args.LastVersion ~= "hide" then
			tbl:tag("th"):wikitext("Last Updated"):done()
                      end
                      if args.Skills == "show" then
			tbl:tag("th"):wikitext("Skills"):done()
                      end
                      if args.Author ~= "hide" then
			tbl:tag("th"):wikitext("Author"):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._pageName .. "|" .. row.Name .. "]]"):done()
                      end
                      if args.Class ~= "hide" then
		        tr:tag("td"):wikitext("[[" .. row.Class .. "]]"):done()
                      end
                      if args.LastVersion ~= "hide" then
		        tr:tag("td"):wikitext(row.LastVersion):done()
                      end
                      if args.Skills == "show" then
		        tr:tag("td"):wikitext(mw.text.listToText( mw.text.split( row.Skills, ',' ) )):done()
                      end
                      if args.Author ~= "hide" then
		        tr:tag("td"):wikitext(row.Author):done()
                      end
	 end
	 return tbl
    end
--  . . .
end
return p
Advertisement