Module:Skill Nodes

From Last Epoch Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:Skill Nodes/doc

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

function p.List( frame )
    local args = frame.args
    local fieldstable = {
	"Name",
	"Description",
	"Icon",
	"MaxPoints",
	"Mods",
        "BaseSkill",
        "SkillEffects",
        "AddedDamageTypes",
        "Connections",
        "NodeType",
        "_pageName",
		}
    local tables = 'SkillNodes'
    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.Icon ~= "hide" then
			tbl:tag("th"):wikitext("Icon"):done()
                      end
                      if args.Name ~= "hide" then
			tbl:tag("th"):wikitext("Node Name"):done()
                      end
                      if args.Description ~= "hide" then
			tbl:tag("th"):wikitext("Node Description"):done()
                      end
                      if args.MaxPoints ~= "hide" then
			tbl:tag("th"):wikitext("Max Points"):done()
                      end
                      if args.Connections ~= "hide" then
			tbl:tag("th"):wikitext("Connected Nodes"):done()
                      end
                      if args.NodeType == "show" then
			tbl:tag("th"):wikitext("Type"):done()
                      end
                      if args.BaseSkill == "show" then
			tbl:tag("th"):wikitext("Skill"):done()
                      end
                      if args.Mods == "show" then
			tbl:tag("th"):wikitext("Mods"):done()
                      end
                      if args.SkillEffects == "show" then
			tbl:tag("th"):wikitext("Skill Effects"):done()
                      end
                      if args.AddedDamageTypes == "show" then
			tbl:tag("th"):wikitext("New Damage Types"):done()
                      end
		tbl:done()
	
         --Construct the rows in the table
	 for _,row in ipairs(result) do
		tr = tbl:tag("tr")
                      if args.Icon ~= "hide" then
		        tr:tag("td"):wikitext(row.Icon):done()
                      end
                      if args.Name ~= "hide" then
		        tr:tag("td"):wikitext("[[" .. row._pageName .. "|" .. row.Name .. "]]"):done()
                      end
                      if args.Description ~= "hide" then
		        tr:tag("td"):wikitext(row.Description):done()
                      end
                      if args.MaxPoints ~= "hide" then
		        tr:tag("td"):wikitext(row.MaxPoints):done()
                      end
                      if args.Connections ~= "hide" then
		        tr:tag("td"):wikitext( mw.text.listToText( mw.text.split( row.Connections, ',' ) ) ):done()
                      end
                      if args.NodeType == "show" then
		        tr:tag("td"):wikitext( (row.NodeType ~= '' and row.NodeType or 'Normal') ):done()
                      end
                      if args.BaseSkill == "show" then
		        tr:tag("td"):wikitext("[[" .. row.BaseSkill .. "]]"):done()
                      end
                      if args.Mods == "show" then
		        tr:tag("td"):wikitext(mw.text.listToText( mw.text.split( row.Mods, ',' ) )):done()
                      end
                      if args.SkillEffects == "show" then
		        tr:tag("td"):wikitext(mw.text.listToText( mw.text.split( row.SkillEffects, ',' ) )):done()
                      end
                      if args.AddedDamageTypes == "show" then
		        tr:tag("td"):wikitext(mw.text.listToText( mw.text.split( row.AddedDamageTypes, ',' ) )):done()
                      end
	 end
	 return tbl
    end
--  . . .
end
return p