Module:Villagers

From Foundation - Wiki
Revision as of 08:18, 24 December 2023 by Sakaratte (talk | contribs) (Created page with "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 rank = com.firstUpper(args[1]) local jobs = {} for k, v in pairs(book) do if v.rank then jobs[k] = true end end table.sort(jobs) if #jobs > 0 then local cols = { 'column-count', (args[2] or 3) } local jobList = mw.html.create('di...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 rank = com.firstUpper(args[1])
		local jobs = {}
		for k, v in pairs(book) do
			if v.rank then
				jobs[k] = true
			end
		end
		
		table.sort(jobs)
		if #jobs > 0 then
			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('[[' .. k .. ']]')
				jobList:node(jobName)
			end
			
			return jobList
		end
	end
		
	return ''
	
end

return p