Module:BuildingTable: Difference between revisions

From Corsair Cove Official Wiki
Dorce (talk | contribs)
No edit summary
Tag: Reverted
Dorce (talk | contribs)
No edit summary
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
return {
local p = {}
["Woodcutter"] = {
 
["name"] = "Woodcutter",
local buildingData = require("Module:BuildingData")
["building_icon_filename"] = "T ICO resource Hardwood.png",
local resourceData = require("Module:ResourceData")
["category"] = "Materials",
 
["theme"] = "",
local function getResourceIcon(resourceName)
["description"] = "",
    local data = resourceData[resourceName]
["unlocked_by_1"] = "",
    if not data then
["unlocked_by_2"] = "",
        return "T Button SelectionBorder Default.png" -- or some other safe fallback
["unlocked_by_3"] = "",
    end
["housing"] = 0,
    if not data.icon_file then
["hands_builders"] = 2,
    return "T Button SelectionBorder Default.png"
["hands_fetchers"] = 0,
    end
["hands_greenhands"] = 2,
    return data.icon_file
["hands_masterhands"] = 0,
end
["hands_upkeep_1"] = "Stew",
 
["hands_upkeep_1_qty"] = 2,
local function stackFormat(inputs)
["hands_upkeep_2"] = "",
    if not inputs then
["hands_upkeep_2_qty"] = 0,
        return "''None''"
["hands_upkeep_3"] = "",
    end
["hands_upkeep_3_qty"] = 0,
 
["construction"] = {
    local parts = {}
{
 
["resource"] = "",
    for _, item in ipairs(inputs) do
["qty"] = 0
        if item.resource ~= "" and (item.qty or 0) > 0 then
},
            table.insert(parts, item.qty .. " [[File:" .. getResourceIcon(item.resource) .. "|16px]] " .. "[[" .. item.resource .. "]]")
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Hardwood",
["production_output_qty"] = 8,
["production_base_per_min"] = 8,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Sawmill"] = {
["name"] = "Sawmill",
["building_icon_filename"] = "",
["category"] = "Materials",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 3,
["hands_fetchers"] = 1,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Hardwood",
["qty"] = 10
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Hardwood",
["qty"] = 4
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Planks",
["production_output_qty"] = 10,
["production_base_per_min"] = 10,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Quarry"] = {
["name"] = "Quarry",
["building_icon_filename"] = "",
["category"] = "Materials",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 2,
["hands_fetchers"] = 0,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 25
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Stone",
["production_output_qty"] = 6,
["production_base_per_min"] = 6,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Stonecutter"] = {
["name"] = "Stonecutter",
["building_icon_filename"] = "",
["category"] = "Materials",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 3,
["hands_fetchers"] = 1,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 12
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Stone",
["qty"] = 2
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Stone Blocks",
["production_output_qty"] = 5,
["production_base_per_min"] = 5,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Charburner"] = {
["name"] = "Charburner",
["building_icon_filename"] = "",
["category"] = "Materials",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 4,
["hands_fetchers"] = 2,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 30
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Hardwood",
["qty"] = 6
},
{
["resource"] = "Stone",
["qty"] = 2
}
},
["production_output"] = "Charcoal",
["production_output_qty"] = 16,
["production_base_per_min"] = 16,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Guano Gatherer"] = {
["name"] = "Guano Gatherer",
["building_icon_filename"] = "",
["category"] = "Weapons",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 2,
["hands_fetchers"] = 0,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 30
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Guano",
["production_output_qty"] = 12,
["production_base_per_min"] = 12,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Powdermill"] = {
["name"] = "Powdermill",
["building_icon_filename"] = "",
["category"] = "Weapons",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 4,
["hands_fetchers"] = 2,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 25
},
{
["resource"] = "Stone Blocks",
["qty"] = 25
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Guano",
["qty"] = 6
},
{
["resource"] = "Charcoal",
["qty"] = 2
}
},
["production_output"] = "Black Powder",
["production_output_qty"] = 10,
["production_base_per_min"] = 10,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Leafcutter"] = {
["name"] = "Leafcutter",
["building_icon_filename"] = "",
["category"] = "Materials",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 2,
["hands_fetchers"] = 0,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 25
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Fibre",
["production_output_qty"] = 12,
["production_base_per_min"] = 12,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Rope Maker"] = {
["name"] = "Rope Maker",
["building_icon_filename"] = "",
["category"] = "Ships",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 3,
["hands_fetchers"] = 1,
["hands_greenhands"] = 2,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 2,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 25
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Fibre",
["qty"] = 4
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Rope",
["production_output_qty"] = 6,
["production_base_per_min"] = 6,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Hardwood Workshop"] = {
["name"] = "Hardwood Workshop",
["building_icon_filename"] = "",
["category"] = "Equipment",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 2,
["hands_fetchers"] = 1,
["hands_greenhands"] = 1,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 1,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 25
},
{
["resource"] = "Stone Blocks",
["qty"] = 15
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Hardwood",
["qty"] = 2
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Wooden Awl",
["production_output_qty"] = 6,
["production_base_per_min"] = 6,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Weaver"] = {
["name"] = "Weaver",
["building_icon_filename"] = "",
["category"] = "Materials",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 5,
["hands_fetchers"] = 2,
["hands_greenhands"] = 3,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 3,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 25
},
{
["resource"] = "Stone Blocks",
["qty"] = 15
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Wooden Awl",
["qty"] = 6
},
{
["resource"] = "Fibre",
["qty"] = 4
}
},
["production_output"] = "Fabric",
["production_output_qty"] = 8,
["production_base_per_min"] = 8,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},
["Sail Maker"] = {
["name"] = "Sail Maker",
["building_icon_filename"] = "",
["category"] = "Ships",
["theme"] = "",
["description"] = "",
["unlocked_by_1"] = "",
["unlocked_by_2"] = "",
["unlocked_by_3"] = "",
["housing"] = 0,
["hands_builders"] = 6,
["hands_fetchers"] = 1,
["hands_greenhands"] = 5,
["hands_masterhands"] = 0,
["hands_upkeep_1"] = "Stew",
["hands_upkeep_1_qty"] = 5,
["hands_upkeep_2"] = "",
["hands_upkeep_2_qty"] = 0,
["hands_upkeep_3"] = "",
["hands_upkeep_3_qty"] = 0,
["construction"] = {
{
["resource"] = "Planks",
["qty"] = 30
},
{
["resource"] = "Stone Blocks",
["qty"] = 20
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
},
["construction_requires_fertile_area"] = false,
["production_input"] = {
{
["resource"] = "Fabric",
["qty"] = 8
},
{
["resource"] = "",
["qty"] = 0
}
},
["production_output"] = "Sails",
["production_output_qty"] = 4,
["production_base_per_min"] = 4,
["production_booster_1"] = "",
["production_booster_2"] = "",
["production_output_storage"] = 0,
["community_upkeep"] = {
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
},
{
["resource"] = "",
["qty"] = 0
}
}
},

Latest revision as of 10:19, 7 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 buildingData = require("Module:BuildingData")
local resourceData = require("Module:ResourceData")

local function getResourceIcon(resourceName)
    local data = resourceData[resourceName]
    if not data then
        return "T Button SelectionBorder Default.png" -- or some other safe fallback
    end
    if not data.icon_file then
    	return "T Button SelectionBorder Default.png"
    end
    return data.icon_file
end

local function stackFormat(inputs)
    if not inputs then
        return "''None''"
    end

    local parts = {}

    for _, item in ipairs(inputs) do
        if item.resource ~= "" and (item.qty or 0) > 0 then
            table.insert(parts, item.qty .. " [[File:" .. getResourceIcon(item.resource) .. "|16px]] " .. "[[" .. item.resource .. "]]")
        end
    end

    if #parts == 0 then
        return "''None''"
    end

    return table.concat(parts, "<br/>")
end

function p.producers(frame)
    local out = {}

    table.insert(out, '{| class="wikitable sortable"')
    table.insert(out, '!class="unsortable"| Icon !! Name !! Category !! Dedicated Workers !! Product !! Input !! Building Cost')

    for _, building in pairs(buildingData) do
        local icon = building.building_icon_filename or "T Button SelectionBorder Default.png"
		if icon == nil or icon == "" then
		    icon = "T Button SelectionBorder Default.png"
		end
		
        local workers = (building.hands_greenhands or 0) + (building.hands_masterhands or 0)

        if workers > 0 and building.production_output ~= "" and building.production_output ~= nil 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

            table.insert(out, "|-")

			local icon2 = getResourceIcon(building.production_output)
			if icon2 == nil then
			    error(string.format(
			        "DEBUG: getResourceIcon returned nil for production_output=%q (building=%s)",
			        tostring(building.production_output), tostring(building.name)
			    ))
			end
			
			table.insert(out,
			    string.format(
			        "|  <div class='cc-producer-icon'>[[File:%s|64px]] || [[%s]] || %s || %d [[Pirates|Greenhands]] || %d [[File:%s|16px]] [[%s]] || %s || %s",
			        icon or "T Button SelectionBorder Default.png",
			        building.name or "",
			        building.category or "",
			        workers or 0,
			        building.production_output_qty or 0,
			        icon2 or "T Button SelectionBorder Default.png",
			        building.production_output or "",
			        stackFormat(building.production_input) or "''None''",
			        stackFormat(building.construction) or "''None''"
			    )
			)
        end
    end

    table.insert(out, "|}")

    return table.concat(out, "\n")
end


function p.housing(frame)
    local out = {}

    table.insert(out, '{| class="wikitable sortable"')
    table.insert(out, '!class="unsortable"| Icon !! Name !! Capacity !! Unlock Requirement !! Building Cost')

    for _, building in pairs(buildingData) do
        local icon = building.building_icon_filename
		if icon == nil or icon == "" then
		    icon = "T Button SelectionBorder Default.png"
		end
		
        if building.housing > 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
	
	        table.insert(out, "|-")
	        table.insert(out,
	            string.format(
	                "|  [[File:%s|64px]] || [[%s]] || %d || %s || %s",
	                icon or "T Button SelectionBorder Default.png",
	                building.name or "",
	                building.housing or 0,
	                building.unlock_requirement or "",
	                stackFormat(building.construction) or "''None''"
	            )
	        )
	    end
    end

    table.insert(out, "|}")

    return table.concat(out, "\n")
end

function p.principle(frame)
    local out = {}

    table.insert(out, '{| class="wikitable sortable"')
    table.insert(out, '!class="unsortable"| Icon !! Name !! Effect !! Unlock Requirement !! Building Cost')

    for _, building in pairs(buildingData) do
        local icon = building.building_icon_filename
		if icon == nil or icon == "" then
		    icon = "T Button SelectionBorder Default.png"
		end
		
        if building.category == "Principle" 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
	
	        table.insert(out, "|-")
	        table.insert(out,
	            string.format(
	                "|  [[File:%s|64px]] || [[%s]] || %s || %s || %s",
	                icon or "T Button SelectionBorder Default.png",
	                building.name or "",
	                building.description or "",
	                building.unlock_requirement or "",
	                stackFormat(building.construction) or "''None''"
	            )
	        )
	    end
    end

    table.insert(out, "|}")

    return table.concat(out, "\n")
end

function p.community(frame)
    local out = {}

    table.insert(out, '{| class="wikitable sortable"')
    table.insert(out, "!class='unsortable'| Icon !! Name !! Dedicated Workers<br/>''Without [[Pirates|Drifters]]'' !! Function !! Resource Input !! Building Cost")

    for _, building in pairs(buildingData) do
        local icon = building.building_icon_filename
		if icon == nil or icon == "" then
		    icon = "T Button SelectionBorder Default.png"
		end
		
        if building.category == "Community" 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
	
	        table.insert(out, "|-")
	        table.insert(out,
	            string.format(
	                "|[[File:%s|64px]] || [[%s]] || %d [[Pirates|Builders]] || %s || %s || %s",
	                icon or "T Button SelectionBorder Default.png",
	                building.name or "",
	                building.hands_builders or 0,
	                building.description or "",
	                stackFormat(building.community_upkeep) or "''None''",
	                stackFormat(building.construction) or "''None''"
	            )
	        )
	    end
    end

    table.insert(out, "|}")

    return table.concat(out, "\n")
end

return p