Module:Sandbox/GauTest/Township: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 376: Line 376:
local production = Shared.clone(building.provides.resources)
local production = Shared.clone(building.provides.resources)
if #production > 0 then
if #production > 0 then
local retProduction = {}
table.insert(ret, '\r\n|-\r\n| <b>Produces:</b><br>')
for _, resource in ipairs(production) do
for _, resource in ipairs(production) do
local retProduction = {}
local job = p._GetJobFromResource(resource.id)
local job = p._GetJobFromResource(resource.id)
local workers = GameData.getEntityByID(building.provides.workers, job).quantity
local workers = GameData.getEntityByID(building.provides.workers, job).quantity
Line 383: Line 384:
local production = workers*resource.quantity*100*(Township.tickLength/10)
local production = workers*resource.quantity*100*(Township.tickLength/10)
local resource_data = GameData.getEntityByID(resources, resource.id)
local resource_data = GameData.getEntityByID(resources, resource.id)
table.insert(retProduction, '<span style="color:green">'..Icons.Icon(p._GetResourceIcon(resource.id))..' -'..production..'</span>')
table.insert(retProduction, '<span style="color:green">'..Icons.Icon(p._GetResourceIcon(resource.id))..' +'..production..'</span>')
if resource_data.requires ~= nil and #resource_data.requires > 0 then
if resource_data.requires ~= nil and #resource_data.requires > 0 then
for _, required_resource in ipairs(resource_data.requires) do
for _, required_resource in ipairs(resource_data.requires) do
local demand = workers*resource.quantity*100*(Township.tickLength/10)
local demand = workers*resource.quantity*100*(Township.tickLength/10)
table.insert(retProduction, '<br><span style="color:red">'..Icons.Icon(p._GetResourceIcon(required_resource.id))..' -'..demand..'</span>')
table.insert(retProduction, '<span style="color:red">'..Icons.Icon(p._GetResourceIcon(required_resource.id))..' -'..demand..'</span>')
end
end
end
end
table.insert(ret, table.concat(retProduction, ', '))
table.insert(ret, '/tick/'..p.GetTownshipStatIcon('Workers'))
end
end
table.insert(ret, '\r\n|-\r\n| <b>Produces:</b><br>')
table.insert(ret, table.concat(retProduction, ', '))
end
end


572

edits