Difference between revisions of "Module:Tables"

Jump to navigation Jump to search
567 bytes added ,  14:46, 21 February 2024
no edit summary
 
(6 intermediate revisions by the same user not shown)
Line 33: Line 33:
for k, v in ipairs(dataTable) do
for k, v in ipairs(dataTable) do
local titleParts = mw.text.split(v, '%s')
for k2, part in ipairs(titleParts) do
titleParts[k2] = part:upper():sub(1,1) .. part:sub(2)
end
local buildString = '[[%s|%s]]'
local pageTitle = table.concat(titleParts, ' ')
local u = string.upper(string.sub(v,1,1))
local u = string.upper(string.sub(v,1,1))
local buildingName = '[[' .. u .. string.sub(v, 2) .. ']]'
local buildingName = buildString:format(pageTitle, u .. string.sub(v, 2))
local c = buildingList[v]
local c = buildingList[v]
local getPreReq = {}
local getPreReq = {}
Line 69: Line 75:
if c.products then
if c.products then
production = production ..'\'\'\'Produces:\'\'\'<br />'
production = production ..'\'\'\'Produces:\'\'\'<br />'
for k, v in pairs(c.production) do
for k, v in ipairs(c.products) do
production = production .. i.icon(v, nil, nil, v, 'en') .. '<br />'
production = production .. i.icon(v, nil, nil, v, 'en') .. '<br />'
end
end
Line 79: Line 85:
end
end
local construction = ''
if c.construction then
for k, v in pairs(c.construction) do
construction = construction .. i.icon(k, v, nil, k, 'en') .. '<br />'
end
local l = string.len(construction)
construction = string.sub(construction, 1, l -6)
end
local newRow = mw.html.create('tr')
local newRow = mw.html.create('tr')
newRow:tag('th')
newRow:tag('th')
Line 88: Line 103:
:tag('td')
:tag('td')
:wikitext(production)
:wikitext(production)
:done()
:tag('td')
:wikitext(construction)
:done()
:done()
buildingTable:node(newRow)
buildingTable:node(newRow)

Navigation menu