T turingmachine Emperor Joined May 4, 2008 Messages 1,438 Mar 9, 2013 #1 I need to check every building in one of my cities. Is there any easy way to do this?
whoward69 DLL Minion Joined May 30, 2011 Messages 8,727 Location Near Portsmouth, UK Mar 9, 2013 #2 There is no way to loop the buildings in the city directly, you have to loop the buildings and see if this city has any Code: for building in GameInfo.Buildings() do if pCity:IsHasBuilding(building.ID) then -- City has this building end end (Above code derived from CityView.lua) Edit: If you are going to do this many times, pre-cache the building IDs into a local list ... it will be a LOT faster
There is no way to loop the buildings in the city directly, you have to loop the buildings and see if this city has any Code: for building in GameInfo.Buildings() do if pCity:IsHasBuilding(building.ID) then -- City has this building end end (Above code derived from CityView.lua) Edit: If you are going to do this many times, pre-cache the building IDs into a local list ... it will be a LOT faster
N NotSoGood Emperor Joined Jan 25, 2009 Messages 1,077 Location Finland Mar 9, 2013 #3 turingmachine said: I need to check every building in one of my cities. Is there any easy way to do this? Click to expand... Well you could loop through every possible building in the game and check if your city has them with the IsHasBuilding.
turingmachine said: I need to check every building in one of my cities. Is there any easy way to do this? Click to expand... Well you could loop through every possible building in the game and check if your city has them with the IsHasBuilding.