Anonymous

Module:Sandbox/GauTest/Township: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 373: Line 373:
end
end


-- Production (todo)
-- Production
table.insert(ret, '\r\n|-\r\n| <b>Produces:</b><br>')
local retProduction = {}
local production = Shared.clone(building.provides.resources)
local production = Shared.clone(building.provides.resources)
for _, resource in ipairs(production) do
if #production > 0 then
local job = p._GetJobFromResource(resource.id)
local retProduction = {}
local workers = GameData.getEntityByID(building.provides.workers, job).quantity
for _, resource in ipairs(production) do
-- township.js -> Township.computeTownResourceGain()
local job = p._GetJobFromResource(resource.id)
local production = workers*resource.quantity*100*(Township.tickLength/10)
local workers = GameData.getEntityByID(building.provides.workers, job).quantity
local resource_data = GameData.getEntityByID(resources, resource.id)
-- township.js -> Township.computeTownResourceGain()
table.insert(retProduction, '<span style="color:green">'..Icons.Icon(p._GetResourceIcon(resource.id))..' -'..production..'</span>')
local production = workers*resource.quantity*100*(Township.tickLength/10)
if resource_data.requires ~= nil and #resource_data.requires > 0 then
local resource_data = GameData.getEntityByID(resources, resource.id)
for _, required_resource in ipairs(resource_data.requires) do
table.insert(retProduction, '<span style="color:green">'..Icons.Icon(p._GetResourceIcon(resource.id))..' -'..production..'</span>')
local demand = workers*resource.quantity*100*(Township.tickLength/10)
if resource_data.requires ~= nil and #resource_data.requires > 0 then
table.insert(retProduction, '<br><span style="color:red">'..Icons.Icon(p._GetResourceIcon(required_resource.id))..' -'..demand..'</span>')
for _, required_resource in ipairs(resource_data.requires) do
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>')
end
end
end
end
end
table.insert(ret, '\r\n|-\r\n| <b>Produces:</b><br>')
table.insert(table.concat(retProduction, ', '))
end
end


572

edits