Difference between revisions of "Module:Tables"

From Foundation - Wiki
Jump to navigation Jump to search
(Created page with "local com = require('Module:Common') local a = require('Module:Args') local i = require('Module:Icon') local p = {} function p.buildings(frame) local buildingList = mw.load('Module:Buildings') local args = a.getArgs(frame) local buildingTable = mw.html.create('table') buildingTable:addClass('wikitable sortable') :tag('tr') :tag('th') :wikitext('Name') :done() :tag('th') :wikitext('Prerequisites')...")
 
Line 8: Line 8:
local args = a.getArgs(frame)
local args = a.getArgs(frame)
local buildingTable = mw.html.create('table')
local buildingTable = mw.html.create('table')
local dataTable = {}
for k, v in pairs(buildingList) do
if v.group == args['group'] or not args['group'] then
table.insert(dataTable, k)
end
end
table.sort(dataTable)
buildingTable:addClass('wikitable sortable')
buildingTable:addClass('wikitable sortable')
    :tag('tr')
:tag('tr')
        :tag('th')
:tag('th')
            :wikitext('Name')
:wikitext('Name')
            :done()
:done()
        :tag('th')
:tag('th')
            :wikitext('Prerequisites')
:wikitext('Prerequisites')
            :done()
:done()
        :tag('th')
:tag('th')
            :wikitext('Production')
:wikitext('Production')
            :done()
:done()
        :tag('th')
:tag('th')
            :wikitext('Construction Requirements')
:wikitext('Construction Requirements')
            :done()
:done()
        :done()
:done()
 
end
end

Revision as of 11:32, 14 August 2022

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

local com = require('Module:Common')
local a = require('Module:Args')
local i = require('Module:Icon')
local p = {}

function p.buildings(frame)
	local buildingList = mw.load('Module:Buildings')
	local args = a.getArgs(frame)
	local buildingTable = mw.html.create('table')
	local dataTable = {}
	for k, v in pairs(buildingList) do
		if v.group == args['group'] or not args['group'] then
			table.insert(dataTable, k)
		end
	end
	
	table.sort(dataTable)
	buildingTable:addClass('wikitable sortable')
		:tag('tr')
			:tag('th')
				:wikitext('Name')
				:done()
			:tag('th')
				:wikitext('Prerequisites')
				:done()
			:tag('th')
				:wikitext('Production')
				:done()
			:tag('th')
				:wikitext('Construction Requirements')
				:done()
			:done()
	  
end