SerialEventCityPopulationChanged: Difference between revisions

From Civilization Modding Wiki
Jump to navigationJump to search
(Created page with "==Description== Fired when a population of a particular city was changed. [http://wiki.2kgames.com/civ5/index.php/Lua_SerialEventCityPopulationChanged Description in the official...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
==Description==
Fired when a population of a particular city was changed.
Fired when a population of a particular [[Lua Game Objects/City|city]] was changed.
[http://wiki.2kgames.com/civ5/index.php/Lua_SerialEventCityPopulationChanged Description in the official wiki] is wrong: event is fired for both human player and AIs, for discovered and yet not discovered cities as well.
 
[http://wiki.2kgames.com/civ5/index.php/Lua_SerialEventCityPopulationChanged Description on the official wiki] is wrong: event is fired for both human player and AIs, for discovered and yet not discovered cities as well.
==Example==
==Example==
   function OnCityPopulationChanged(x, y, newPop)
   function OnCityPopulationChanged(x, y, newPop)

Latest revision as of 08:55, 14 February 2012

Description

Fired when a population of a particular city was changed.

Description on the official wiki is wrong: event is fired for both human player and AIs, for discovered and yet not discovered cities as well.

Example

 function OnCityPopulationChanged(x, y, newPop)
   local pPlot = Map.GetPlot(ToGridFromHex(x, y))
   local pCity = pPlot:GetPlotCity()
   local pPlayer = Players[pCity:GetOwner()]
   DoSomething(pCity)
 end
 Events.SerialEventCityPopulationChanged.Add(OnCityPopulationChanged)