<?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_Visual</id>
	<title>Mod API Reference:Client Visual - 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_Visual"/>
	<link rel="alternate" type="text/html" href="https://war.app/wiki/index.php?title=Mod_API_Reference:Client_Visual&amp;action=history"/>
	<updated>2026-10-19T16:15:43Z</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_Visual&amp;diff=8039&amp;oldid=prev</id>
		<title>Fizzer at 20:38, 3 October 2026</title>
		<link rel="alternate" type="text/html" href="https://war.app/wiki/index.php?title=Mod_API_Reference:Client_Visual&amp;diff=8039&amp;oldid=prev"/>
		<updated>2026-10-03T20:38:55Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:38, 3 October 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l7&quot;&gt;Line 7:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== When it runs ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== When it runs ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The client calls &amp;lt;code&amp;gt;Client_Visual&amp;lt;/code&amp;gt; each time it needs to show a [[Mod API Reference:GameOrderEvent|GameOrderEvent]] that was created by your mod. Events created inside your mod&#039;s server hooks (for example with &amp;lt;code&amp;gt;addNewOrder(WL.GameOrderEvent.Create(...))&amp;lt;/code&amp;gt;) are tagged with your mod automatically. The hook is not called for any other order type.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The client calls &amp;lt;code&amp;gt;Client_Visual&amp;lt;/code&amp;gt; each time it needs to show a [[Mod API Reference:GameOrderEvent|GameOrderEvent]] that was created by your mod. Events created inside your mod&#039;s server hooks (for example with &amp;lt;code&amp;gt;addNewOrder(WL.GameOrderEvent.Create(...))&amp;lt;/code&amp;gt;) are tagged with your mod automatically. The hook is &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;currently &lt;/ins&gt;not called for any other order type&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, but it may be in the future so you should still check &quot;order&quot; properly to ensure it&#039;s the one you are looking for&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The visual appears together with the event&amp;#039;s other effects:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The visual appears together with the event&amp;#039;s other effects:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Fizzer</name></author>
	</entry>
	<entry>
		<id>https://war.app/wiki/index.php?title=Mod_API_Reference:Client_Visual&amp;diff=8038&amp;oldid=prev</id>
		<title>Fizzer at 20:37, 3 October 2026</title>
		<link rel="alternate" type="text/html" href="https://war.app/wiki/index.php?title=Mod_API_Reference:Client_Visual&amp;diff=8038&amp;oldid=prev"/>
		<updated>2026-10-03T20:37:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:37, 3 October 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Client_Visual&amp;#039;&amp;#039;&amp;#039; is a client-side [[Mod Hooks|mod hook]] that lets a mod draw its own shapes on the map for the events it creates. Shapes are made of colored triangles. They can be a single static shape, or animated by giving several keyframes that the game tweens between when a player watches the turn.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Client_Visual&amp;#039;&amp;#039;&amp;#039; is a client-side [[Mod Hooks|mod hook]] that lets a mod draw its own shapes on the map for the events it creates. Shapes are made of colored triangles. They can be a single static shape, or animated by giving several keyframes that the game tweens between when a player watches the turn.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note to website users: If you play in 2d mode, this hook will never be called.  Custom visuals are not supported in the legacy 2d website mode.  It is fully supported in the website&#039;s 3d mode, as well as all other clients (iOS, Android, standalone, etc.)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note this mod hook was added in version 6.06.0.  Mods don&#039;t need to call &quot;IsVersionOrHigher&quot;, since the hook will simply not be called in earlier versions.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== When it runs ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== When it runs ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Fizzer</name></author>
	</entry>
	<entry>
		<id>https://war.app/wiki/index.php?title=Mod_API_Reference:Client_Visual&amp;diff=8037&amp;oldid=prev</id>
		<title>Fizzer: Created page with &quot;&#039;&#039;&#039;Client_Visual&#039;&#039;&#039; is a client-side mod hook that lets a mod draw its own shapes on the map for the events it creates. Shapes are made of colored triangles. They can be a single static shape, or animated by giving several keyframes that the game tweens between when a player watches the turn.  == When it runs ==  The client calls &lt;code&gt;Client_Visual&lt;/code&gt; each time it needs to show a GameOrderEvent that was created by y...&quot;</title>
		<link rel="alternate" type="text/html" href="https://war.app/wiki/index.php?title=Mod_API_Reference:Client_Visual&amp;diff=8037&amp;oldid=prev"/>
		<updated>2026-10-03T20:35:26Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;Client_Visual&amp;#039;&amp;#039;&amp;#039; is a client-side &lt;a href=&quot;/wiki/Mod_Hooks&quot; title=&quot;Mod Hooks&quot;&gt;mod hook&lt;/a&gt; that lets a mod draw its own shapes on the map for the events it creates. Shapes are made of colored triangles. They can be a single static shape, or animated by giving several keyframes that the game tweens between when a player watches the turn.  == When it runs ==  The client calls &amp;lt;code&amp;gt;Client_Visual&amp;lt;/code&amp;gt; each time it needs to show a &lt;a href=&quot;/wiki/Mod_API_Reference:GameOrderEvent&quot; title=&quot;Mod API Reference:GameOrderEvent&quot;&gt;GameOrderEvent&lt;/a&gt; that was created by y...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Client_Visual&amp;#039;&amp;#039;&amp;#039; is a client-side [[Mod Hooks|mod hook]] that lets a mod draw its own shapes on the map for the events it creates. Shapes are made of colored triangles. They can be a single static shape, or animated by giving several keyframes that the game tweens between when a player watches the turn.&lt;br /&gt;
&lt;br /&gt;
== When it runs ==&lt;br /&gt;
&lt;br /&gt;
The client calls &amp;lt;code&amp;gt;Client_Visual&amp;lt;/code&amp;gt; each time it needs to show a [[Mod API Reference:GameOrderEvent|GameOrderEvent]] that was created by your mod. Events created inside your mod&amp;#039;s server hooks (for example with &amp;lt;code&amp;gt;addNewOrder(WL.GameOrderEvent.Create(...))&amp;lt;/code&amp;gt;) are tagged with your mod automatically. The hook is not called for any other order type.&lt;br /&gt;
&lt;br /&gt;
The visual appears together with the event&amp;#039;s other effects:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Watching the turn&amp;#039;&amp;#039;&amp;#039;: when the event is played back, an animated visual plays from start to finish. The game then moves on to the next order.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Viewing the event at any other time&amp;#039;&amp;#039;&amp;#039; (clicking it in the orders list, stepping through history, or &amp;quot;Show All&amp;quot;): the visual is drawn in its &amp;#039;&amp;#039;rest pose&amp;#039;&amp;#039; (see [[#SetRestTime|SetRestTime]]). When the event is shown faded, the visual is drawn at half opacity.&lt;br /&gt;
&lt;br /&gt;
Because the hook runs every time the event is displayed, it should be quick and should always produce the same result for the same order. Don&amp;#039;t rely on state left over from earlier calls.&lt;br /&gt;
&lt;br /&gt;
Visuals are not drawn when the web client is showing the map in 2D mode.&lt;br /&gt;
&lt;br /&gt;
== Signature ==&lt;br /&gt;
&lt;br /&gt;
Put the function in a file named &amp;lt;code&amp;gt;Client_Visual.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function Client_Visual(game, order, visual)&lt;br /&gt;
    -- describe the visual by calling functions on visual&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&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]] || The same client game object that other client hooks receive. Use it to read the map, settings, and standings.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;order&amp;lt;/code&amp;gt; || [[Mod API Reference:GameOrderEvent|GameOrderEvent]] || The event being displayed. Read-only. Use its fields (such as &amp;lt;code&amp;gt;Message&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TerritoryModifications&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;JumpToActionSpotOpt&amp;lt;/code&amp;gt;) to decide what to draw and where.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;visual&amp;lt;/code&amp;gt; || table || The object you describe the visual with. See [[#Functions|Functions]] below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If your hook doesn&amp;#039;t call &amp;lt;code&amp;gt;SetVertices&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;SetFrames&amp;lt;/code&amp;gt;, no visual is drawn and the event displays as it normally would. That&amp;#039;s the right thing to do for events you don&amp;#039;t want to draw.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Every function on &amp;lt;code&amp;gt;visual&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;visual&amp;lt;/code&amp;gt;, so calls can be chained. Call them with a dot (&amp;lt;code&amp;gt;visual.SetDuration(500)&amp;lt;/code&amp;gt;), not a colon. A colon passes &amp;lt;code&amp;gt;visual&amp;lt;/code&amp;gt; as the first argument, which causes an error.&lt;br /&gt;
&lt;br /&gt;
The order of the calls doesn&amp;#039;t matter. The game collects everything after your hook returns, then checks it as a whole.&lt;br /&gt;
&lt;br /&gt;
=== SetVertices ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetVertices(vertices)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the corner points of a visual that doesn&amp;#039;t animate. &amp;lt;code&amp;gt;vertices&amp;lt;/code&amp;gt; is a list of points. Each point is &amp;lt;code&amp;gt;{x, y}&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;{x, y, z}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Coordinates are in map units, the same units as the map&amp;#039;s SVG and the territory positions. &amp;#039;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;#039; increases to the right and &amp;#039;&amp;#039;&amp;#039;y&amp;#039;&amp;#039;&amp;#039; increases &amp;#039;&amp;#039;downward&amp;#039;&amp;#039;.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;z&amp;#039;&amp;#039;&amp;#039; is optional and defaults to 0. Positive z lifts the point toward the viewer. It only makes a difference when the map is viewed in 3D.&lt;br /&gt;
* If an anchor is set (see [[#SetAnchorTerritory|SetAnchorTerritory]] and [[#SetAnchorPoint|SetAnchorPoint]]), coordinates are relative to the anchor. Otherwise they are absolute map coordinates.&lt;br /&gt;
* At most 1024 vertices. Each coordinate must be between -100000 and 100000.&lt;br /&gt;
&lt;br /&gt;
If you also call &amp;lt;code&amp;gt;SetFrames&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SetFrames&amp;lt;/code&amp;gt; wins and &amp;lt;code&amp;gt;SetVertices&amp;lt;/code&amp;gt; is ignored. A warning is written to the mod log.&lt;br /&gt;
&lt;br /&gt;
=== SetTriangles ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetTriangles(indices)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets which vertices form triangles. &amp;lt;code&amp;gt;indices&amp;lt;/code&amp;gt; is a flat list of vertex numbers, three per triangle. Numbering starts at &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;, like the rest of Lua. For example, &amp;lt;code&amp;gt;{1,2,3, 1,3,4}&amp;lt;/code&amp;gt; makes a rectangle out of four corners.&lt;br /&gt;
&lt;br /&gt;
* The number of indices must be a multiple of 3, and every index must be between 1 and the number of vertices.&lt;br /&gt;
* At most 2048 triangles.&lt;br /&gt;
* Winding order doesn&amp;#039;t matter, because both sides of every triangle are drawn.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Optional.&amp;#039;&amp;#039;&amp;#039; If you don&amp;#039;t call it, every three vertices in a row form one triangle (vertices 1–3, then 4–6, and so on). The vertex count must then be a multiple of 3.&lt;br /&gt;
&lt;br /&gt;
The same triangles are used for every frame of an animation.&lt;br /&gt;
&lt;br /&gt;
=== SetColors ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetColors(colors)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the colors of the vertices. You can pass either:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;one color&amp;#039;&amp;#039;&amp;#039;, used for every vertex, or&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;a list of colors&amp;#039;&amp;#039;&amp;#039;, one per vertex in the same order as the vertices. Colors blend smoothly across each triangle.&lt;br /&gt;
&lt;br /&gt;
A color can be written as:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Form !! Example !! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;#RRGGBB&amp;quot;&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;quot;#FF0000&amp;quot;&amp;lt;/code&amp;gt; || Fully opaque.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;#AARRGGBB&amp;quot;&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;quot;#80FF0000&amp;quot;&amp;lt;/code&amp;gt; || &amp;#039;&amp;#039;&amp;#039;Alpha comes first.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;80&amp;lt;/code&amp;gt; is about 50% opacity.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;{r, g, b}&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;{255, 0, 0}&amp;lt;/code&amp;gt; || Each value 0–255. Fully opaque.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;{r, g, b, a}&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;{255, 0, 0, 128}&amp;lt;/code&amp;gt; || Each value 0–255. Alpha comes last in this form.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Optional.&amp;#039;&amp;#039;&amp;#039; Vertices are white if no colors are given. In an animation, &amp;lt;code&amp;gt;SetColors&amp;lt;/code&amp;gt; supplies the colors for the first frame if that frame doesn&amp;#039;t have its own (see [[#SetFrames|SetFrames]]).&lt;br /&gt;
&lt;br /&gt;
=== SetFrames ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetFrames(frames)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Describes an animated visual as a list of keyframes. The game tweens the position and color of every vertex from one keyframe to the next. Each frame is a table with these keys:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Key !! Required !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Vertices&amp;lt;/code&amp;gt; || Yes || The vertices for this pose, in the same format as [[#SetVertices|SetVertices]]. &amp;#039;&amp;#039;&amp;#039;Every frame must have the same number of vertices.&amp;#039;&amp;#039;&amp;#039; Vertex 3 in one frame moves to vertex 3 in the next.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Colors&amp;lt;/code&amp;gt; || No || Colors for this pose, in the same format as [[#SetColors|SetColors]]. If left out, the frame uses the previous frame&amp;#039;s colors. The first frame falls back to &amp;lt;code&amp;gt;SetColors&amp;lt;/code&amp;gt;, then to white.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; || No || When this pose is reached, as a fraction of the duration from 0 (start) to 1 (end). Each frame&amp;#039;s &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; must not be less than the frame before it. Either give every frame a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; or none of them. If none have one, the frames are spread evenly from 0 to 1.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Ease&amp;lt;/code&amp;gt; || No || How the tween that &amp;#039;&amp;#039;&amp;#039;ends at this frame&amp;#039;&amp;#039;&amp;#039; is paced. One of &amp;lt;code&amp;gt;Linear&amp;lt;/code&amp;gt; (the default), &amp;lt;code&amp;gt;EaseIn&amp;lt;/code&amp;gt; (starts slow), &amp;lt;code&amp;gt;EaseOut&amp;lt;/code&amp;gt; (ends slow), &amp;lt;code&amp;gt;EaseInOut&amp;lt;/code&amp;gt; (slow at both ends) or &amp;lt;code&amp;gt;Step&amp;lt;/code&amp;gt; (holds the previous pose, then jumps to this one when its &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; is reached). Not case-sensitive. The first frame&amp;#039;s ease is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* At most 32 frames.&lt;br /&gt;
* Before the first frame&amp;#039;s &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, the visual holds the first pose. After the last frame&amp;#039;s &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, it holds the last pose.&lt;br /&gt;
* A visual with only one frame doesn&amp;#039;t animate. It behaves the same as &amp;lt;code&amp;gt;SetVertices&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== SetDuration ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetDuration(milliseconds)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How long the animation lasts when the turn is watched. Defaults to 1000 (one second). Values are limited to 1–10000. Out-of-range values are clamped and a warning is written to the mod log. The player&amp;#039;s playback speed setting scales the actual time.&lt;br /&gt;
&lt;br /&gt;
Only matters for animated visuals.&lt;br /&gt;
&lt;br /&gt;
=== SetRestTime ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetRestTime(t)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picks which moment of the animation is shown when the visual is &amp;#039;&amp;#039;not&amp;#039;&amp;#039; being played: when the event is clicked, viewed in history, or shown with &amp;quot;Show All&amp;quot;. It&amp;#039;s also the pose the visual returns to after playback finishes or is interrupted. &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; is from 0 to 1, where 0 is the first pose and 1 is the last. Defaults to 1, the final pose.&lt;br /&gt;
&lt;br /&gt;
For example, an explosion that grows and then fades to nothing should use a rest time in the middle, such as 0.4. Otherwise the event would look empty when it&amp;#039;s clicked.&lt;br /&gt;
&lt;br /&gt;
=== SetAnchorTerritory ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetAnchorTerritory(territoryID)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes vertex coordinates relative to the middle of a territory, so &amp;lt;code&amp;gt;{0, 0}&amp;lt;/code&amp;gt; is that territory&amp;#039;s center. This is the easiest way to place a visual on a territory without knowing its map coordinates.&lt;br /&gt;
&lt;br /&gt;
If the territory doesn&amp;#039;t exist on the map, no visual is drawn.&lt;br /&gt;
&lt;br /&gt;
=== SetAnchorPoint ===&lt;br /&gt;
&amp;lt;code&amp;gt;visual.SetAnchorPoint(x, y)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes vertex coordinates relative to a point on the map, given in map units.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SetAnchorTerritory&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SetAnchorPoint&amp;lt;/code&amp;gt; replace each other: whichever you call last is used. If you call neither, vertex coordinates are absolute map coordinates.&lt;br /&gt;
&lt;br /&gt;
== Limits ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Limit !! Value&lt;br /&gt;
|-&lt;br /&gt;
| Vertices || 1024&lt;br /&gt;
|-&lt;br /&gt;
| Triangles || 2048&lt;br /&gt;
|-&lt;br /&gt;
| Frames || 32&lt;br /&gt;
|-&lt;br /&gt;
| Duration || 1 to 10000 ms&lt;br /&gt;
|-&lt;br /&gt;
| Coordinates || -100000 to 100000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
&lt;br /&gt;
There are two kinds of problems:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Wrong argument types&amp;#039;&amp;#039;&amp;#039;, such as passing a string to &amp;lt;code&amp;gt;SetVertices&amp;lt;/code&amp;gt; or a malformed color. These raise a normal Lua error when the function is called, the same as any other mod error.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Problems that depend on the whole visual&amp;#039;&amp;#039;&amp;#039;, such as frames with different vertex counts, a triangle index out of range, or an anchor territory that doesn&amp;#039;t exist. These don&amp;#039;t raise an error, because the hook runs every time the event is shown. Instead, no visual is drawn and a message starting with &amp;lt;code&amp;gt;Client_Visual:&amp;lt;/code&amp;gt; is written to the mod&amp;#039;s log. If your visual doesn&amp;#039;t appear, check the log first.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== A basic rectangle ===&lt;br /&gt;
&lt;br /&gt;
A semi-transparent red rectangle, 40 by 20 map units, centered on the first territory the event modifies:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function Client_Visual(game, order, visual)&lt;br /&gt;
    local terrMods = order.TerritoryModifications&lt;br /&gt;
    if #terrMods == 0 then&lt;br /&gt;
        return -- nothing to anchor to, so don&amp;#039;t draw anything&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    visual.SetAnchorTerritory(terrMods[1].TerritoryID)&lt;br /&gt;
          .SetVertices({ {-20, -10}, {20, -10}, {20, 10}, {-20, 10} })&lt;br /&gt;
          .SetTriangles({ 1,2,3, 1,3,4 })&lt;br /&gt;
          .SetColors(&amp;quot;#B0FF0000&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The four vertices are the corners, going clockwise from the top left. &amp;lt;code&amp;gt;SetTriangles&amp;lt;/code&amp;gt; splits the rectangle into two triangles. You could leave out &amp;lt;code&amp;gt;SetTriangles&amp;lt;/code&amp;gt; and list six vertices instead (two triangles of three), but sharing corners is shorter.&lt;br /&gt;
&lt;br /&gt;
=== An animated rectangle ===&lt;br /&gt;
&lt;br /&gt;
A bar that grows out of the territory&amp;#039;s center to the right, turns from yellow to red, then fades away:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function Client_Visual(game, order, visual)&lt;br /&gt;
    local terrMods = order.TerritoryModifications&lt;br /&gt;
    if #terrMods == 0 then&lt;br /&gt;
        return&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- A rectangle from x=0 to x=len, 10 units tall&lt;br /&gt;
    local function bar(len)&lt;br /&gt;
        return { {0, -5}, {len, -5}, {len, 5}, {0, 5} }&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    visual.SetAnchorTerritory(terrMods[1].TerritoryID)&lt;br /&gt;
          .SetTriangles({ 1,2,3, 1,3,4 })&lt;br /&gt;
          .SetDuration(1500)&lt;br /&gt;
          .SetRestTime(0.6) -- when not playing, show it fully grown and red&lt;br /&gt;
          .SetFrames({&lt;br /&gt;
              { t = 0,   Vertices = bar(0),  Colors = &amp;quot;#FFFFFF00&amp;quot; },&lt;br /&gt;
              { t = 0.6, Vertices = bar(80), Colors = &amp;quot;#FFFF0000&amp;quot;, Ease = &amp;quot;EaseOut&amp;quot; },&lt;br /&gt;
              { t = 1,   Vertices = bar(80), Colors = &amp;quot;#00FF0000&amp;quot;, Ease = &amp;quot;EaseIn&amp;quot; },&lt;br /&gt;
          })&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How it plays:&lt;br /&gt;
* From &amp;lt;code&amp;gt;t = 0&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;0.6&amp;lt;/code&amp;gt; (the first 900 ms), the bar grows from zero to 80 units long and turns from yellow to red. &amp;lt;code&amp;gt;EaseOut&amp;lt;/code&amp;gt; makes it slow down as it reaches full length.&lt;br /&gt;
* From &amp;lt;code&amp;gt;0.6&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, it stays the same size while its alpha drops to &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt;, so it fades out. &amp;lt;code&amp;gt;EaseIn&amp;lt;/code&amp;gt; makes the fade start gently.&lt;br /&gt;
* &amp;lt;code&amp;gt;SetRestTime(0.6)&amp;lt;/code&amp;gt; means a player who clicks the event later sees the full red bar. With the default rest time of 1, they&amp;#039;d see the faded-out final pose, which is invisible.&lt;br /&gt;
&lt;br /&gt;
=== A gradient triangle at a fixed point ===&lt;br /&gt;
&lt;br /&gt;
Per-vertex colors and an anchor point instead of a territory. No &amp;lt;code&amp;gt;SetTriangles&amp;lt;/code&amp;gt; call is needed, because three vertices are one triangle:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function Client_Visual(game, order, visual)&lt;br /&gt;
    visual.SetAnchorPoint(500, 300)&lt;br /&gt;
          .SetVertices({ {0, -30}, {26, 15}, {-26, 15} })&lt;br /&gt;
          .SetColors({ &amp;quot;#FF0000&amp;quot;, &amp;quot;#00FF00&amp;quot;, &amp;quot;#0000FF&amp;quot; })&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating the event on the server ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Client_Visual&amp;lt;/code&amp;gt; only draws events that your mod created. For example, in &amp;lt;code&amp;gt;Server_AdvanceTurn_End.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function Server_AdvanceTurn_End(game, addNewOrder)&lt;br /&gt;
    local terrID = 1 -- pick whichever territory your mod is affecting&lt;br /&gt;
    local terrMod = WL.TerritoryModification.Create(terrID)&lt;br /&gt;
    terrMod.AddArmies = 2&lt;br /&gt;
&lt;br /&gt;
    addNewOrder(WL.GameOrderEvent.Create(WL.PlayerID.Neutral, &amp;quot;Reinforcements arrive&amp;quot;, nil, { terrMod }))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your mod creates several kinds of events, check &amp;lt;code&amp;gt;order.Message&amp;lt;/code&amp;gt; (or another field) in &amp;lt;code&amp;gt;Client_Visual&amp;lt;/code&amp;gt; to decide which visual to draw. Return without calling anything for events that shouldn&amp;#039;t have one.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Mod Hooks]]&lt;br /&gt;
* [[Mod API Reference:GameOrderEvent]]&lt;br /&gt;
* [[Mod API Reference:ClientGame]]&lt;/div&gt;</summary>
		<author><name>Fizzer</name></author>
	</entry>
</feed>