Module:BuildingTable: Difference between revisions
From Corsair Cove Official Wiki
Created page with "local p = {} local data = require("Module:BuildingData") function p.producers(frame) local out = {} table.insert(out, '{| class="wikitable sortable"') table.insert(out, '! Icon !! Name !! Category !! Dedicated Workers !! Product !! Input !! Building Cost') for _, building in pairs(data) do local workers = (building.hands_greenhands or 0) + (building.hands_masterhands or 0) if workers > 0 then local cost = "''None''"..." |
m 76561199005532951 moved page Module:TableProductionBuilding to Module:BuildingTable without leaving a redirect: Avoiding parallel scripts |
(No difference)
| |
Revision as of 10:26, 1 August 2026
This module can display buildings from the 4 separate major categories.
- Housing
- Production
- Community
- Principle
Each category table displays relevant stats for that respective category.
local p = {}
local data = require("Module:BuildingData")
function p.producers(frame)
local out = {}
table.insert(out, '{| class="wikitable sortable"')
table.insert(out, '! Icon !! Name !! Category !! Dedicated Workers !! Product !! Input !! Building Cost')
for _, building in pairs(data) do
local workers = (building.hands_greenhands or 0) + (building.hands_masterhands or 0)
if workers > 0 then
local cost = "''None''"
-- Build construction cost string
local parts = {}
for _, item in ipairs(building.construction or {}) do
if item.qty > 0 and item.resource ~= "" then
table.insert(parts,
string.format("%d [[%s]]", item.qty, item.resource))
end
end
if #parts > 0 then
cost = table.concat(parts, "<br>")
end
table.insert(out, "|-")
table.insert(out,
string.format(
"| {{Producer icon|%s|size=lg}} || [[%s]] || %s || %d [[Pirates|Greenhands]] || [[%s]] || %s || %s",
building.building_icon_filename,
building.name,
building.category,
workers,
building.product or "",
building.input or "''None''",
cost
)
)
end
end
table.insert(out, "|}")
return table.concat(out, "\n")
end
return p


