<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://war.app/index.php?action=history&amp;feed=atom&amp;title=Mod_API_Reference%3AClient_TurnAdvanced</id>
	<title>Mod API Reference:Client TurnAdvanced - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://war.app/index.php?action=history&amp;feed=atom&amp;title=Mod_API_Reference%3AClient_TurnAdvanced"/>
	<link rel="alternate" type="text/html" href="https://war.app/wiki/index.php?title=Mod_API_Reference:Client_TurnAdvanced&amp;action=history"/>
	<updated>2026-11-04T15:05:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://war.app/wiki/index.php?title=Mod_API_Reference:Client_TurnAdvanced&amp;diff=8045&amp;oldid=prev</id>
		<title>Fizzer: Created page with &quot; Put the function in a file named &lt;code&gt;Client_TurnAdvanced.lua&lt;/code&gt;:  &lt;pre&gt; function Client_TurnAdvanced(game, previousNumberOfTurns) end &lt;/pre&gt;  The client calls this hook when it loads or refreshes a game that has more turns than the last time this device showed it. That includes: * a turn that advances while the player has the game open * turns that advanced while the player was away, which the hook sees when they next open the game  {| class=&quot;wikitable&quot; ! Argument...&quot;</title>
		<link rel="alternate" type="text/html" href="https://war.app/wiki/index.php?title=Mod_API_Reference:Client_TurnAdvanced&amp;diff=8045&amp;oldid=prev"/>
		<updated>2026-11-02T10:52:50Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; Put the function in a file named &amp;lt;code&amp;gt;Client_TurnAdvanced.lua&amp;lt;/code&amp;gt;:  &amp;lt;pre&amp;gt; function Client_TurnAdvanced(game, previousNumberOfTurns) end &amp;lt;/pre&amp;gt;  The client calls this hook when it loads or refreshes a game that has more turns than the last time this device showed it. That includes: * a turn that advances while the player has the game open * turns that advanced while the player was away, which the hook sees when they next open the game  {| class=&amp;quot;wikitable&amp;quot; ! Argument...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
Put the function in a file named &amp;lt;code&amp;gt;Client_TurnAdvanced.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function Client_TurnAdvanced(game, previousNumberOfTurns)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The client calls this hook when it loads or refreshes a game that has more turns than the last time this device showed it. That includes:&lt;br /&gt;
* a turn that advances while the player has the game open&lt;br /&gt;
* turns that advanced while the player was away, which the hook sees when they next open the game&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Argument !! Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;game&amp;lt;/code&amp;gt; || [[Mod API Reference:ClientGame|ClientGame]] || Information about the game. &amp;lt;code&amp;gt;game.Game.NumberOfTurns&amp;lt;/code&amp;gt; is the number of turns now.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;previousNumberOfTurns&amp;lt;/code&amp;gt; || number || How many turns the game had the last time this device showed it.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* If several turns advanced, the hook is called once. Compare &amp;lt;code&amp;gt;game.Game.NumberOfTurns&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;previousNumberOfTurns&amp;lt;/code&amp;gt; to see how many.&lt;br /&gt;
* It isn&amp;#039;t called the first time a device shows a game, since there&amp;#039;s nothing to compare against.&lt;br /&gt;
* It isn&amp;#039;t called when the number of turns goes down, such as when a single-player level is restarted.&lt;br /&gt;
* The device remembers each game&amp;#039;s turn count for each signed-in player. A player who views the game on two devices gets the hook on each of them.&lt;br /&gt;
* It runs after Client_GameRefresh.&lt;br /&gt;
&lt;br /&gt;
It works well with UI.SetMenuBadge and Mod.ClientStorage. For example, this shows how many turns are new until the player opens the mod&amp;#039;s menu:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- Client_TurnAdvanced.lua&lt;br /&gt;
function Client_TurnAdvanced(game, previousNumberOfTurns)&lt;br /&gt;
    UI.SetMenuBadge(tostring(game.Game.NumberOfTurns - previousNumberOfTurns));&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Client_PresentMenuUI.lua&lt;br /&gt;
function Client_PresentMenuUI(rootParent, setMaxSize, setScrollable, game, close)&lt;br /&gt;
    UI.SetMenuBadge(nil);&lt;br /&gt;
    ...&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fizzer</name></author>
	</entry>
</feed>