Player.Cities (Civ5 API)

From Civilization Modding Wiki
Jump to: navigation, search

This page is a part of the Lua and UI Reference (Civ5).


Function.png This function is a member of Player.

This is an instance method, invoke it with a colon.


Returns all of a player's cities. Must be used in a for loop because it's an iterator function (see example)


Usage

iterator(City) Player:Cities()


Returned Value

Iterator over all of a player's cities


Examples

for City in Player:Cities() do
...
end
local pPlayer = Players[Game.GetActivePlayer()]
for pCity in pPlayer:Cities() do
print("City ID ",pCity:GetID()," Population is ",pCity:GetPopulation())
end


Source code samples

Redundant occurences have been removed.

CityList.lua

UI/InGame/CityList.lua
0100
for pCity in pPlayer:Cities() do


GPList.lua

UI/InGame/GPList.lua
0197
for pCity in player:Cities() do


TradeLogic.lua

UI/InGame/WorldView/TradeLogic.lua
1267
for pCity in g_pUs:Cities() do
1285
for pCity in g_pThem:Cities() do
2463
for pCity in m_pFrom:Cities() do


TurnsRemaining.lua (G&K)

DLC/Expansion/Scenarios/FallOfRomeScenario/TurnsRemaining.lua
0414
for pCity in Players[playerID]:Cities() do


TutorialChecks.lua

Tutorial/TutorialChecks.lua
0257
for v in player:Cities() do
2524
for v in pOtherPlayer:Cities() do
2750
for v in pPlayer:Cities() do


WhosWinningPopup.lua

UI/InGame/Popups/WhosWinningPopup.lua
0192
for pLoopCity in pPlayer:Cities() do



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.