Anonymous

Module:Township: Difference between revisions

From Melvor Idle
_GetBuildingBenefits: Added worship support
(Tavern/Gardens production fix)
(_GetBuildingBenefits: Added worship support)
(One intermediate revision by the same user not shown)
Line 303: Line 303:
-- Gets a Township building by ID, e.g. melvorF:Hunters_Cabin
-- Gets a Township building by ID, e.g. melvorF:Hunters_Cabin
function p._GetBuildingByID(id)
function p._GetBuildingByID(id)
return GameData.getEntityByID(Township.buildings, id)
-- Check for the special statue case
if id == 'melvorF:Statues' then
local building = Shared.clone(GameData.getEntityByID(Township.buildings, id))
building.name = 'Statue of Worship'
return building
else
return GameData.getEntityByID(Township.buildings, id)
end
end
end


-- Gets a Township building by name, e.g. Hunters Cabin
-- Gets a Township building by name, e.g. Hunters Cabin
function p._GetBuildingByName(name)
function p._GetBuildingByName(name)
return GameData.getEntityByName(Township.buildings, name)
-- Check for the special statue case
if name == 'STATUE_NAME' then
name = 'Statue of Worship'
end
local STATUE_OF = 'Statue of '
if string.sub(name, 1, string.len(STATUE_OF)) == STATUE_OF then
local building = Shared.clone(GameData.getEntityByName(Township.buildings, 'STATUE_NAME'))
building.name = name
return building
else
return GameData.getEntityByName(Township.buildings, name)
end
end
end


Line 450: Line 468:
education = 'Education',
education = 'Education',
storage = 'Storage',
storage = 'Storage',
deadStorage = 'Dead Storage'
deadStorage = 'Dead Storage',
worship = 'Worship'
}
}
for key, stat in pairs(stats) do
for key, stat in pairs(stats) do
572

edits