Anonymous

Module:Sandbox/GauTest/Township: Difference between revisions

From Melvor Idle
no edit summary
(Refactoring)
No edit summary
Line 496: Line 496:
function p._GetResourceByID(id)
function p._GetResourceByID(id)
return GameData.getEntityByID(p.resources, id)
return GameData.getEntityByID(p.resources, id)
end
-- Returns an upgrade table of a building
function p.GetBuildingUpgradeTable(buildingname)
local building = p._GetBuildingByName(buildingname)
-- Let's find the base building
local baseBuilding = building
while true do
local previousBuilding = p._GetBuildingDowngrade(baseBuilding)
if previousBuilding ~= nil then
baseBuilding = previousBuilding
else
break
end
end
-- Let's make a list of all the buildings
local buildingList = {}
local _curBuilding = baseBuilding
while true do
table.insert(buildingList, _curBuilding)
_curBuilding = p._GetBuildingIDUpgrade(_curBuilding.id)
if _curBuilding == nil then
break
end
end
local ret = {}
table.insert(ret, '\r\n{| class="wikitable"')
-- Name
table.insert(ret, '\r\n|-\r\n')
for _, building in ipairs(buildingList) do
table.insert(ret, '!'..building.name)
end
-- End
table.insert(ret, '\r\n|}')
mw.log(table.concat(ret))
return table.concat(ret)
end
end


return p
return p
572

edits