Anonymous

Module:Township: Difference between revisions

From Melvor Idle
Add statue support
(Tavern/Gardens production fix)
(Add statue support)
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


572

edits