Looping Buildings

gargoyle575

Chieftain
Joined
Jan 20, 2012
Messages
94
I'm trying to loop through all cities in the game and then find the cities with a certain building in them.

Code:
function LoopBuildings()
	print("Looping Buildings...")
	for i = 0, Game.CountCivPlayersAlive() do
		local aPlayer = Players[i]
		for pCity in aPlayer:Cities() do
			for building in GameInfo.Buildings() do
				if pCity:IsHasBuilding(GameInfo.Buildings.BUILDING_BANK.ID) then
					print("Name:",pCity:GetName(),"Building present")
				end
			end
		end
	end
end

It does what it's supposed to do but when it gets to printing the name of the city and "Building present", firetuner prints it at least 40 times in a row. For every city that has one. Is there a way to fix this?
 
Code:
function LoopBuildings()
	print("Looping Buildings...")
	for i = 0, Game.CountCivPlayersAlive() do
		local aPlayer = Players[i]
		for pCity in aPlayer:Cities() do
			[s]for building in GameInfo.Buildings() do[/s]
				if pCity:IsHasBuilding(GameInfo.Buildings.BUILDING_BANK.ID) then
					print("Name:",pCity:GetName(),"Building present")
				end
			[s]end[/s]
		end
	end
end
 
Top Bottom