<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://modiki.civfanatics.com/index.php?action=history&amp;feed=atom&amp;title=Events.SerialEventCityPopulationChanged_%28Civ5_API%29</id>
	<title>Events.SerialEventCityPopulationChanged (Civ5 API) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://modiki.civfanatics.com/index.php?action=history&amp;feed=atom&amp;title=Events.SerialEventCityPopulationChanged_%28Civ5_API%29"/>
	<link rel="alternate" type="text/html" href="https://modiki.civfanatics.com/index.php?title=Events.SerialEventCityPopulationChanged_(Civ5_API)&amp;action=history"/>
	<updated>2026-04-11T06:23:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://modiki.civfanatics.com/index.php?title=Events.SerialEventCityPopulationChanged_(Civ5_API)&amp;diff=10914&amp;oldid=prev</id>
		<title>DonQuich: Bot update</title>
		<link rel="alternate" type="text/html" href="https://modiki.civfanatics.com/index.php?title=Events.SerialEventCityPopulationChanged_(Civ5_API)&amp;diff=10914&amp;oldid=prev"/>
		<updated>2012-09-19T18:48:12Z</updated>

		<summary type="html">&lt;p&gt;Bot update&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Civ5 API Beta Banner}}&lt;br /&gt;
&amp;#039;&amp;#039;This page is a part of the [[Lua and UI Reference (Civ5)]].&amp;#039;&amp;#039;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{TypeInfos5|Function.png|This function is a member of {{Type5|Events}}.&amp;lt;br/&amp;gt;&lt;br /&gt;
This is a static method, invoke it with a dot.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This event is triggered every time the population of a city changes. The triggering city need not belong to the active (human) player, although the city needs to have been discovered by that player. Cities that the active player has no knowledge of will not trigger this event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Usage=&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;#039;&amp;#039;&amp;#039;void&amp;#039;&amp;#039;&amp;#039; Events.SerialEventCityPopulationChanged&amp;lt;b&amp;gt;(&amp;lt;/b&amp;gt;&amp;#039;&amp;#039;&amp;#039;float&amp;#039;&amp;#039;&amp;#039; hexX, &amp;#039;&amp;#039;&amp;#039;int&amp;#039;&amp;#039;&amp;#039; hexY, &amp;#039;&amp;#039;&amp;#039;int&amp;#039;&amp;#039;&amp;#039; newPop, &amp;#039;&amp;#039;&amp;#039;int&amp;#039;&amp;#039;&amp;#039; unknown&amp;lt;b&amp;gt;)&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Event Type&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
:Regular event: you can subscribe to it through &amp;lt;code&amp;gt;Events.SerialEventCityPopulationChanged.Add(&amp;#039;&amp;#039;&amp;lt;function handler&amp;gt;&amp;#039;&amp;#039;)&amp;lt;/code&amp;gt; or invoke it directly through &amp;lt;code&amp;gt;Events.SerialEventCityPopulationChanged(&amp;#039;&amp;#039;&amp;lt;arguments list&amp;gt;&amp;#039;&amp;#039;)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
:{|&lt;br /&gt;
|-&lt;br /&gt;
|valign=&amp;quot;top&amp;quot; style=&amp;quot;padding-right:6px;&amp;quot;|hexX:&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;| &amp;#039;&amp;#039;Hex x-coordinate of the city whose population changed which can be converted to map grid coordinates with the {{Type5|ToGridFromHex}} function (see example)&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|valign=&amp;quot;top&amp;quot; style=&amp;quot;padding-right:6px;&amp;quot;|hexY:&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;| &amp;#039;&amp;#039;Hex y-coordinate of the city whose population changed which can be converted to map grid coordinates with the {{Type5|ToGridFromHex}} function (see example)&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|valign=&amp;quot;top&amp;quot; style=&amp;quot;padding-right:6px;&amp;quot;|newPop:&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;| &amp;#039;&amp;#039;the new population of the city whose population changed&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|valign=&amp;quot;top&amp;quot; style=&amp;quot;padding-right:6px;&amp;quot;|unknown:&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;| &amp;#039;&amp;#039;unsure what the meaning of this argument is, although it would always seem to be half of iNewPop, rounded up; possibly related to city graphics&amp;#039;&amp;#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; class=&amp;quot;civ5-example&amp;quot;&amp;gt;&lt;br /&gt;
function onCityPopulationChanged(iHexX, iHexY, iPopulation, iUnknown )&lt;br /&gt;
local pPlot = Map.GetPlot(ToGridFromHex(iHexX, iHexY))&lt;br /&gt;
local pCity = pPlot:GetPlotCity()&lt;br /&gt;
local iOwner = pCity:GetOwner()&lt;br /&gt;
print(string.format(&amp;quot;%s (owned by %s) has grown to size %d&amp;quot;, pCity:GetName(), Players[iOwner]:GetName(), iPopulation))&lt;br /&gt;
end&lt;br /&gt;
Events.SerialEventCityPopulationChanged.Add(onCityPopulationChanged)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Source code samples=&lt;br /&gt;
{{PseudoH4|DebugMode.lua}}&lt;br /&gt;
:&amp;lt;code&amp;gt;UI/InGame/DebugMode.lua&amp;lt;/code&amp;gt;&lt;br /&gt;
:{{CodeBegin5}}&lt;br /&gt;
{{CodeLine5|0167}}&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;Events.SerialEventCityPopulationChanged( g_iHexX, g_iHexY, g_iPopulation, iCitySize );&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{CodeEnd5}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Civ5 API Footer}}&lt;br /&gt;
[[Category:Civ5 Methods and Functions|SerialEventCityPopulationChanged]]&lt;br /&gt;
[[Category:Civ5 Cities API|SerialEventCityPopulationChanged]]&lt;br /&gt;
[[Category:Civ5 Food &amp;amp; Population API|SerialEventCityPopulationChanged]]&lt;/div&gt;</summary>
		<author><name>DonQuich</name></author>
	</entry>
</feed>