Difference between revisions of "Module:Villagers"
Jump to navigation
Jump to search
Tag: Manual revert |
|||
| Line 7: | Line 7: | ||
local args = a.getArgs(frame) | local args = a.getArgs(frame) | ||
if args[1] then | if args[1] then | ||
local | local flobber = com.fUpper(args[1]) | ||
local jobs = {} | local jobs = {} | ||
for k, v in pairs(b) do | for k, v in pairs(b) do | ||
if v.rank == | if v.rank == flobber then | ||
-- amay4672: v.rank looks at anything called rank in Module:Buildings | -- amay4672: v.rank looks at anything called rank in Module:Buildings | ||
jobs[k] = true | jobs[k] = true | ||
Revision as of 07:31, 26 January 2026
Documentation for this module may be created at Module:Villagers/doc
local p = {}
local b = mw.loadData('Module:Buildings')
local a = require('Module:Arguments')
local com = require('Module:Common')
function p.jobs(frame)
local args = a.getArgs(frame)
if args[1] then
local flobber = com.fUpper(args[1])
local jobs = {}
for k, v in pairs(b) do
if v.rank == flobber then
-- amay4672: v.rank looks at anything called rank in Module:Buildings
jobs[k] = true
-- amay4672: I think [k] throughout refers to the building names from Module:Buildings
end
end
--amay4672: reasonably sure that here until :tag is all template creation
table.sort(jobs)
mw.log(#jobs)
local cols = {
['column-count'] = (args[2] or 3)
}
local jobList = mw.html.create('div')
jobList:addClass('job-list')
:css(cols)
:tag('ul')
for k, v in pairs(jobs) do
local jobName = mw.html.create('li')
jobName:wikitext('[[' .. com.fUpper(k) .. ']]' .. ((b[k].job and ' - ' .. b[k].job) or ''))
-- amay4672: evidently com.fUpper(k) here is what creates the hyperlinked building name
jobList:node(jobName)
end
return jobList
end
return ''
end
return p