Anonymous

Module:Sandbox/GauTest/Township: Difference between revisions

From Melvor Idle
no edit summary
(moved _GetResourceIcon into Icons.Icon)
No edit summary
Line 347: Line 347:
local cost = {}
local cost = {}
for _, resource in ipairs(building.cost) do
for _, resource in ipairs(building.cost) do
table.insert(cost, Icons.Icon({resource.name, type='resource', notext=true})..' '..resource.quantity)
local resource_data = GameData.getEntityByID(resources, resource.id)
table.insert(cost, Icons.Icon({resource_data.name, type='resource', notext=true})..' '..resource.quantity)
end
end
table.insert(ret, '<b>Base Cost:</b> '..table.concat(cost, ', '))
table.insert(ret, '<b>Base Cost:</b> '..table.concat(cost, ', '))
Line 361: Line 362:
local upgrade_cost = {}
local upgrade_cost = {}
for _, resource in ipairs(upgradesTo[1].cost) do
for _, resource in ipairs(upgradesTo[1].cost) do
table.insert(upgrade_cost, Icons.Icon({resource.name, type='resource', notext=true})..'&nbsp;'..resource.quantity)
local resource_data = GameData.getEntityByID(resources, resource.id)
table.insert(upgrade_cost, Icons.Icon({resource_data.name, type='resource', notext=true})..'&nbsp;'..resource.quantity)
end
end
table.insert(ret, '<br><b>Upgrade Base Cost:</b> '..table.concat(upgrade_cost, ', '))
table.insert(ret, '<br><b>Upgrade Base Cost:</b> '..table.concat(upgrade_cost, ', '))
Line 396: Line 398:
local production = resource.quantity*100*(Township.tickLength/10)
local production = 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({resource.name, type='resource', notext=true})..'&nbsp;+'..production..'</span>')
table.insert(retProduction, '<span style="color:green">'..Icons.Icon({resource_data.name, type='resource', notext=true})..'&nbsp;+'..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 = production*required_resource.quantity*100
local demand = production*required_resource.quantity*100
table.insert(retProduction, '<span style="color:red">'..Icons.Icon({required_resource.name, type='resource', notext=true})..'&nbsp;-'..demand..'</span>')
local required_resource_data = GameData.getEntityByID(resources, resource.id)
table.insert(retProduction, '<span style="color:red">'..Icons.Icon({required_resource_data.name, type='resource', notext=true})..'&nbsp;-'..demand..'</span>')
end
end
end
end
Line 443: Line 446:
return job.id
return job.id
end
end


-- Testing
-- Testing
572

edits