Anonymous

Module:Sandbox/GauTest/Township: Difference between revisions

From Melvor Idle
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
table.insert(ret, '\r\n|-\r\n| <b>Produces:</b><br>')
table.insert(ret, '\r\n|-\r\n| <b>Base Production:</b><br>')
local retResources = {}
local retResources = {}
for _, resource in ipairs(production) do
for _, resource in ipairs(production) do
Line 400: Line 400:
-- Modifiers
-- Modifiers
if building.modifiers ~= nil and not Shared.tableIsEmpty(building.modifiers) then
if building.modifiers ~= nil and not Shared.tableIsEmpty(building.modifiers) then
table.insert(ret, "\r\n|-\r\n| <b>Modifiers:</b>\r\n"..Constants.getModifiersText(building.modifiers, true))
table.insert(ret, '\r\n|-\r\n| <b>Modifiers:</b>\r\n'..Constants.getModifiersText(building.modifiers, true))
end
-- Biomes
table.insert(ret, '\r\n|-\r\n| <b>Biomes:</b><br><ul>')
for _, biomeid in ipairs(building.biomes) do
local biomename = GameData.getEntityByID(Township.biomes, biomeid)
-- Optional hidden bonus/penalty for building
local modifier = GameData.getEntityByProperty(building.biomeModifiers, 'biomeID', biome)
if modifier ~= nil then
local color = modifier.value < 0 and 'red' or 'green'
local modifier_value = Shared.numStrWithSign(modifier.value)
table.insert(ret, '<li style="color:'..color..'"><b>'..biomename..' ('..modifier_value..'%)</b></li>')
else
table.insert(ret, '<li>'..biomename..'</li>')
end
end
end
572

edits