Module:ListSkills
Jump to navigation
Jump to search
Module used by the Skills pages to list types of skills.
Usage
Takes the following arguments as filters. Results will be filtered to match your input.
skilltype
= corresponds to the "skilltype" parameter on a Skill infobox.- One of: "Active" or "Passive"
subtype
= corresponds to the "subtype" parameter for active skills only.- Refer to the headings on the Active Skills page. Don't include "_Skills" in your input.
skilltier
= corresponds to the "skilltier" parameter on a Skill infobox- One of: 1, 2, 3, Quest, Starter
The above documentation is transcluded from Module:ListSkills/doc. (edit | history)
local p = {}
function p.main(frame)
if frame == mw.getCurrentFrame() then
args = require('Module:ProcessArgs').merge(true)
else
frame = mw.getCurrentFrame()
end
local fields = [[Skills._pageName=_pageName,
Skills.name=name,
Skills.image=image,
Descriptions.description=description,
Skills.requires=requires,
Skills.consumes=consumes,
Skills.cooldown=cooldown,
Skills.skilltype=skilltype,
Skills.subtype=subtype,
Skills.skilltier=skilltier,
Skills.trainer=trainer,
Skills.location=location,
Skills.cost=cost,
Skills.prereq=prereq]]
local wheres = ''
if (args.skilltype ~= nil) then
wheres = wheres .. 'skilltype="' .. args.skilltype .. '"'
end
if (args.subtype ~= nil) then
if wheres ~= '' then wheres = wheres .. ' AND ' end
wheres = wheres .. 'subtype="' .. args.subtype .. '"'
end
if (args.skilltier ~= nil) then
if wheres ~= '' then wheres = wheres .. ' AND ' end
wheres = wheres .. 'skilltier="' .. args.skilltier .. '"'
end
local cargoArgs = {
where = wheres,
orderBy = 'Skills.name',
join = 'Skills.name = Descriptions.name',
}
local result = p.doQuery(fields, cargoArgs)
if not result then
return ''
end
local html = mw.html.create()
local tbl = html:tag('table'):addClass('wikitable sortable')
-- header row
local trHeader = tbl:tag('tr')
trHeader:tag('th'):wikitext('Image')
trHeader:tag('th'):wikitext('Name')
trHeader:tag('th'):cssText('min-width:350px;'):wikitext('Description')
if (args.skilltype == 'Passive') then
trHeader:tag('th'):wikitext('Tier')
trHeader:tag('th'):wikitext('Cost')
trHeader:tag('th'):wikitext('Acquisition')
else
trHeader:tag('th'):wikitext('Required')
trHeader:tag('th'):wikitext('Consumes')
trHeader:tag('th'):wikitext('Cooldown')
trHeader:tag('th'):wikitext('Tier')
trHeader:tag('th'):wikitext('Cost')
trHeader:tag('th'):wikitext('Acquisition')
end
for _, row in ipairs(result) do
local tr = tbl:tag('tr')
-- image
tr:tag('td'):cssText('text-align: center;'):wikitext(frame:preprocess('[[File:' .. row.image .. '|x65px|frameless|link=' .. row._pageName .. ']]'))
-- name
tr:tag('td'):wikitext(frame:preprocess('[[' .. row._pageName .. '|' .. row.name .. ']]'))
-- description
tr:tag('td'):wikitext(frame:preprocess(row.description))
if (args.skilltype == 'Passive') then
tr:tag('td'):wikitext(row.skilltier)
if (row.skilltier == 'Quest') then
tr:tag('td'):wikitext(frame:preprocess('<i>n/a</i>'))
tr:tag('td'):wikitext(frame:preprocess(row.prereq))
else
tr:tag('td'):wikitext(frame:preprocess(row.cost))
tr:tag('td'):wikitext(frame:preprocess(row.trainer))
end
else
tr:tag('td'):wikitext(frame:preprocess(row.requires))
tr:tag('td'):wikitext(frame:preprocess(row.consumes))
tr:tag('td'):wikitext(row.cooldown)
tr:tag('td'):wikitext(row.skilltier)
tr:tag('td'):wikitext(row.cost or '<i>None</i>')
tr:tag('td'):wikitext(frame:preprocess(row.trainer))
end
end
return html
end
function p.doQuery(fields, cargoArgs)
local result = mw.ext.cargo.query('Skills,Descriptions', fields, cargoArgs)
if not next(result) then
return nil
else
return result
end
end
function split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
return p