Is there a way to loop through all the buildings in a city

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
 
Back
Top Bottom