<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://newgrf-specs.tt-wiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gesia</id>
	<title>GRFSpecs - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://newgrf-specs.tt-wiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gesia"/>
	<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/wiki/Special:Contributions/Gesia"/>
	<updated>2026-05-14T09:26:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=Callbacks&amp;diff=3463</id>
		<title>Callbacks</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=Callbacks&amp;diff=3463"/>
		<updated>2013-10-19T11:46:33Z</updated>

		<summary type="html">&lt;p&gt;Gesia: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
A callback is a special action 2 that the patch &amp;quot;calls&amp;quot; in order to modify various features, an example being the visual effect of train vehicles. &amp;amp;nbsp;See the [[ttwiki:CallbacksTut|callback tutorial]] on how to use them.&lt;br /&gt;
&lt;br /&gt;
In the final action 2 of a chain of VarAction2s, the second byte of the matching entry has to have bit 7 set to identify it as a callback result.&lt;br /&gt;
&lt;br /&gt;
For example, 04 00 is not a callback result (but it may be the ID of another chained action 2), whereas 04 80 is a callback result with a value of 4. In total a callback has 15 bit result values, where the upper 7 bits are stored in the second byte. For example, 54 C2 is a callback result with a value of 4254=16980, where again the second byte has bit 7 set, changing the 42 into C2.&lt;br /&gt;
&lt;br /&gt;
{{grfTill|7}} For GRF version 7 and below not all 15 bit values are available as return values, only values between 00 and 7EFF.&lt;br /&gt;
For compatibility with earlier patch versions, FF in the high byte is taken to mean the same thing as 80, so 04 FF also has a callback result of 4. Note that if your grf file needs to be compatible with versions before TTDPatch 2.0.1 alpha 40, you must set the high byte to FF, and so can use only 8 bit results.&lt;br /&gt;
&lt;br /&gt;
{{grfFrom|8}} For GRF version 8 and above this compatibility layer has been removed. Callbacks can return all 15 bit values between 00 and 7FFF.&lt;br /&gt;
&lt;br /&gt;
To check for a specific callback, use an [[VariationalAction2]] or [[VarAction2Advanced]] to check for variable 0C.&lt;br /&gt;
* Variable 0C contains the callback number.&lt;br /&gt;
* Variable 0C is a word, thus the VarAction2 must use type 85.&lt;br /&gt;
* Results can be specified directly using 8xxx values (see above), or with 8xxx value in subsequent (Basic/Variational/Random)Action2 which are referenced as usual with their set-id.&lt;br /&gt;
* The default case of the VarAction2 must point to the regular graphics chain, so that unknown/future callbacks results in a &amp;quot;callback failure&amp;quot; result.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;Sprite-number&amp;gt; * &amp;lt;Length&amp;gt; 02 &amp;lt;feature&amp;gt; &amp;lt;set-id&amp;gt; 85 0C 00 \wxFFFF&lt;br /&gt;
                               &amp;lt;nvar&amp;gt; (&amp;lt;set-id/result&amp;gt; \wx &amp;lt;callback&amp;gt; \wx &amp;lt;callback&amp;gt;){n}&lt;br /&gt;
                                       &amp;lt;set-id of graphics chain&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The format for VarAction2 is explained in detail on the [[VariationalAction2]] page.&lt;br /&gt;
&lt;br /&gt;
Note: Some NewGRFs still use type 81 for callbacks. However, testing callbacks with type 81 has been depreciated since 2005/2006 and should not be used. It only still works because new callback IDs were assigned in a backwards-compatible way.&lt;br /&gt;
&lt;br /&gt;
== List of callbacks ==&lt;br /&gt;
&lt;br /&gt;
The following callbacks are defined by the patch. &amp;amp;nbsp;The number of the callback is what will be stored in variable 0C so that you can return the right results if you have several callbacks. &amp;amp;nbsp;All callbacks are explained in more detail below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;PLEASE NOTE:&#039;&#039;&#039; Since TTDPatch 2.5 beta 5, the size of variable 0C has changed, and now there are word-sized callback numbers as well. To maintain backwards compatibility, only callbacks 10..3F can be checked using a byte-sized check. Callbacks 140 and above, on the other hand, must be checked using a word or dword sized check, to make sure they are identified uniquely.&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!Number!!Feature(s)!!Meaning&lt;br /&gt;
|-&lt;br /&gt;
|10||Vehicles||[[Callback: Visual effect and wagon power|Visual effect and wagon power]]&lt;br /&gt;
|-&lt;br /&gt;
|11||Vehicles||[[Callback: Wagon length|Wagon length]]&lt;br /&gt;
|-&lt;br /&gt;
|12||Vehicles||[[Callback: Load amount|Load amount]]&lt;br /&gt;
|-&lt;br /&gt;
|13||Stations||[[Callback: Station availability|Station availability]]&lt;br /&gt;
|-&lt;br /&gt;
|14||Stations||[[Callback: Station sprite layout|Select sprite layout]]&lt;br /&gt;
|-&lt;br /&gt;
|15||Vehicles||[[Callback: Refitted capacity callback|Refitted capacity callback]]&lt;br /&gt;
|-&lt;br /&gt;
|16||Trains||[[Callback: Articulated engine|Build articulated engines]]&lt;br /&gt;
|-&lt;br /&gt;
|17||Houses||[[Callback: House construction check|House construction check]]&lt;br /&gt;
|-&lt;br /&gt;
|18||Several &amp;lt;ref name=&amp;quot;generic&amp;quot;&amp;gt;Generic callbacks are called for the feature, not any specific vehicle ID. Read the [[Action3#n-id|Action 3]] entry on how to define these.&amp;lt;/ref&amp;gt;||[[Callback: AI construction/purchase selection|AI construction/purchase selection]]&lt;br /&gt;
|-&lt;br /&gt;
|19||Vehicles||[[Callback: Cargo Subtype Display|Cargo sub-type display]]&lt;br /&gt;
|-&lt;br /&gt;
|1A||Houses||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|1B||Houses||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|1C||Houses||Construction stage changes&lt;br /&gt;
|-&lt;br /&gt;
|1D||Trains||Can wagon be attached&lt;br /&gt;
|-&lt;br /&gt;
|1E||Houses||Decide colour of building&lt;br /&gt;
|-&lt;br /&gt;
|1F||Houses||Cargo acceptance&lt;br /&gt;
|-&lt;br /&gt;
|20||Houses||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|21||Houses||Trigger building destruction&lt;br /&gt;
|-&lt;br /&gt;
|22||Industries||Availability&lt;br /&gt;
|-&lt;br /&gt;
|23||Vehicles||Additional text in purchase screen&lt;br /&gt;
|-&lt;br /&gt;
|24||Stations||Custom station layout&lt;br /&gt;
|-&lt;br /&gt;
|25||Industry tiles||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|26||Industry tiles||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|27||Industry tiles||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|28||Industries||Industry location permissibility&lt;br /&gt;
|-&lt;br /&gt;
|29||Industries||Random production change&lt;br /&gt;
|-&lt;br /&gt;
|2A||Houses||Get accepted cargo types&lt;br /&gt;
|-&lt;br /&gt;
|2B||Industry tiles||Decide cargo acceptance&lt;br /&gt;
|-&lt;br /&gt;
|2C||Industry tiles||Get accepted cargo types&lt;br /&gt;
|-&lt;br /&gt;
|2D||Vehicles||Select colour mapping for vehicle&lt;br /&gt;
|-&lt;br /&gt;
|2E||Houses||Custom cargo production&lt;br /&gt;
|-&lt;br /&gt;
|2F||Industry tiles||Custom shape check&lt;br /&gt;
|-&lt;br /&gt;
|30||Industry tiles||Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|31||Vehicles||Start/stop check&lt;br /&gt;
|-&lt;br /&gt;
|32||Vehicles||32-day callback&lt;br /&gt;
|-&lt;br /&gt;
|33||Several||Sound effect callback&lt;br /&gt;
|-&lt;br /&gt;
|34||Vehicles &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||Autoreplace vehicle selection&lt;br /&gt;
|-&lt;br /&gt;
|35||Industries||Monthly random production change&lt;br /&gt;
|-&lt;br /&gt;
|36||Vehicles||Change vehicle Properties&lt;br /&gt;
|-&lt;br /&gt;
|37||Industries||Cargo sub-type display&lt;br /&gt;
|-&lt;br /&gt;
|38||Industries||Show additional text in fund window&lt;br /&gt;
|-&lt;br /&gt;
|39||Cargoes||Custom profit calculation&lt;br /&gt;
|-&lt;br /&gt;
|3A||Industries||Show additional text in industry window&lt;br /&gt;
|-&lt;br /&gt;
|3B||Industries||Control special effects&lt;br /&gt;
|-&lt;br /&gt;
|3C||Industry tiles||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|3D||Industries||Opt out of accepting cargo&lt;br /&gt;
|-&lt;br /&gt;
|40..13F|| ||--Reserved--&lt;br /&gt;
|-&lt;br /&gt;
|140||Stations||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|141||Stations||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|142||Stations||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|143||Houses||Protect building conditionally&lt;br /&gt;
|-&lt;br /&gt;
|144||Sounds &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||{{ottdp|1.2|2.6|ottdrev=r23144|ttdprev=r821}} Ambient sound effects&lt;br /&gt;
|-&lt;br /&gt;
|145||Cargoes||Custom station rating calculation&lt;br /&gt;
|-&lt;br /&gt;
|146||New Signals &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||New signals sprite drawing&lt;br /&gt;
|-&lt;br /&gt;
|147||Canals||Add sprite offset&lt;br /&gt;
|-&lt;br /&gt;
|148||Houses||Watched cargo accepted&lt;br /&gt;
|-&lt;br /&gt;
|149||Stations||Land slope check&lt;br /&gt;
|-&lt;br /&gt;
|14A||Industries||Decide industry color&lt;br /&gt;
|-&lt;br /&gt;
|14B||Industries||Decide input cargo types&lt;br /&gt;
|-&lt;br /&gt;
|14C||Industries||Decide output cargo types&lt;br /&gt;
|-&lt;br /&gt;
|14D||Houses||Customized building name&lt;br /&gt;
|-&lt;br /&gt;
|14E||Houses||Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|14F||Houses||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|150||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|152||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Animation control&lt;br /&gt;
|-&lt;br /&gt;
|153||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Next Animation frame&lt;br /&gt;
|-&lt;br /&gt;
|154||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|155||Airports||{{ottdp|1.1|no|ottdrev=r20373}} Extra information about airport layout in the build gui&lt;br /&gt;
|-&lt;br /&gt;
|156||Airports||{{ottdp|1.1|no|ottdrev=r20373}} Airport layout name&lt;br /&gt;
|-&lt;br /&gt;
|157||Objects||Land slope check&lt;br /&gt;
|-&lt;br /&gt;
|158||Objects||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|159||Objects||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|15A||Objects||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|15B||Objects||Decide colour of building&lt;br /&gt;
|-&lt;br /&gt;
|15C||Objects||Show additional text in building window&lt;br /&gt;
|-&lt;br /&gt;
|15D||Objects||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|15E||Vehicles||{{ottdp|1.2|no|ottdrev=r23124}} Refit cost factor&lt;br /&gt;
|-&lt;br /&gt;
|15F||Industries||{{ottdp|1.3|no|ottdrev=r24186}} Set initial production level on construction&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Callback: Visual effect and wagon power}}&lt;br /&gt;
{{:Callback: Wagon length}}&lt;br /&gt;
{{:Callback: Load amount}}&lt;br /&gt;
{{:Callback: Station availability}}&lt;br /&gt;
{{:Callback: Station sprite layout}}&lt;br /&gt;
{{:Callback: Refitted capacity callback}}&lt;br /&gt;
{{:Callback: Articulated engine}}&lt;br /&gt;
{{:Callback: House construction check}}&lt;br /&gt;
{{:Callback: AI construction/purchase selection}}&lt;br /&gt;
{{:Callback: Cargo Subtype Display}}&lt;br /&gt;
{{:Callback: Next animation frame}}&lt;br /&gt;
{{:Callback: Animation control}}&lt;br /&gt;
{{:Callback: Construction stage changes}}&lt;br /&gt;
{{:Callback: Can wagon be attached}}&lt;br /&gt;
{{:Callback: Building colour}}&lt;br /&gt;
{{:Callback: Cargo acceptance}}&lt;br /&gt;
{{:Callback: Length of animation frame}}&lt;br /&gt;
{{:Callback: Trigger building destruction}}&lt;br /&gt;
{{:Callback: Industry availability}}&lt;br /&gt;
{{:Callback: Additional text in purchase screen}}&lt;br /&gt;
{{:Callback: Custom station layout}}&lt;br /&gt;
{{:Callback: Industry location permissibility}}&lt;br /&gt;
{{:Callback: Random production change}}&lt;br /&gt;
{{:Callback: Get accepted cargo types}}&lt;br /&gt;
{{:Callback: Decide cargo acceptance}}&lt;br /&gt;
{{:Callback: Select colour mapping for vehicle}}&lt;br /&gt;
{{:Callback: Custom cargo production}}&lt;br /&gt;
{{:Callback: Custom shape check}}&lt;br /&gt;
{{:Callback: Decide drawing default foundations}}&lt;br /&gt;
{{:Callback: Vehicle Start/stop check}}&lt;br /&gt;
{{:Callback: 32-day callback}}&lt;br /&gt;
{{:Callback: Sound effect}}&lt;br /&gt;
{{:Callback: Autoreplace vehicle selection}}&lt;br /&gt;
{{:Callback: Monthly random production change}}&lt;br /&gt;
{{:Callback: Change vehicle properties}}&lt;br /&gt;
{{:Callback: Cargo sub-type display for industries}}&lt;br /&gt;
{{:Callback: Show additional text in fund/building window}}&lt;br /&gt;
{{:Callback: Custom profit calculation for cargoes}}&lt;br /&gt;
{{:Callback: Show additional text in industry window}}&lt;br /&gt;
{{:Callback: Control special industry effects}}&lt;br /&gt;
{{:Callback: Disable autosloping}}&lt;br /&gt;
{{:Callback: Opt out of accepting cargo}}&lt;br /&gt;
{{:Callback: Protect building conditionally}}&lt;br /&gt;
{{:Callback: Ambient sound effects}}&lt;br /&gt;
{{:Callback: Custom station rating calculation}}&lt;br /&gt;
{{:Callback: New signals sprite drawing callback}}&lt;br /&gt;
{{:Callback: Add sprite offset callback}}&lt;br /&gt;
{{:Callback: Watched cargo accepted}}&lt;br /&gt;
{{:Callback: Station slope check}}&lt;br /&gt;
{{:Callback: Decide industry colour}}&lt;br /&gt;
{{:Callback: Decide input and output cargo types}}&lt;br /&gt;
{{:Callback: Customized building name}}&lt;br /&gt;
{{:Callback: Extra information about layout in the build gui}}&lt;br /&gt;
{{:Callback: Layout name}}&lt;br /&gt;
{{:Callback: Object slope check}}&lt;br /&gt;
{{:Callback: Decide object colour}}&lt;br /&gt;
{{:Callback: Refit cost factor}}&lt;br /&gt;
{{:Callback: Set initial production level on construction}}&lt;/div&gt;</summary>
		<author><name>Gesia</name></author>
	</entry>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=Talk:Callbacks&amp;diff=3462</id>
		<title>Talk:Callbacks</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=Talk:Callbacks&amp;diff=3462"/>
		<updated>2013-10-19T11:44:50Z</updated>

		<summary type="html">&lt;p&gt;Gesia: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Gesia|Gesia]] ([[User talk:Gesia|talk]]) 21:48, 17 October 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
The new introduction states that variable 1C is a word and therefore type 85 must be used. &lt;br /&gt;
&lt;br /&gt;
However, the paragraph below mentions variable 0C and some GRFs (e.g. Ikarus 6) use type 81, which seems to work ingame:&lt;br /&gt;
&lt;br /&gt;
   81 * 9	 02 01 02 01 01 00 00 00 00&lt;br /&gt;
   82 * 14	 02 01 10 &#039;&#039;&#039;&#039;&#039;81 0C&#039;&#039;&#039;&#039;&#039; 00 FF 01 02 FF 23 23 02 00&lt;br /&gt;
   83 * 7	 00 01 01 01 02 0E FF&lt;br /&gt;
   84 * 10	 03 01 01 02 01 FF 10 00 A1 00&lt;br /&gt;
&lt;br /&gt;
I&#039;m guessing some relevant information is still missing?&lt;br /&gt;
&lt;br /&gt;
--[[User:Frosch|Frosch]] ([[User talk:Frosch|talk]]) 18:06, 18 October 2013 (UTC)&lt;br /&gt;
1C was wrong, I copied that from your example :p It&#039;s in fact 0C.&lt;br /&gt;
&lt;br /&gt;
Testing callbacks with type 81 was deprecated 2005 or 2006. It should no longer be used. It only still works because new callback IDs were assigned in a way, so that old NewGRF do not break. That&#039;s the reason why there is a gap from 3E to 13F.&lt;br /&gt;
&lt;br /&gt;
--[[User:Gesia|Gesia]] ([[User talk:Gesia|talk]]) 11:44, 19 October 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
How smart of me to point out my own mistakes as somebody elses, isn&#039;t it? Seriously though: sorry, that was pretty stupid.&lt;br /&gt;
&lt;br /&gt;
After having a closer look it seems to me that several well known NewGRFs actually use type 81. Hence, I took the liberty of adding your answer (in slightly modified form) to the introduction.&lt;/div&gt;</summary>
		<author><name>Gesia</name></author>
	</entry>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=Callbacks&amp;diff=3461</id>
		<title>Callbacks</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=Callbacks&amp;diff=3461"/>
		<updated>2013-10-19T11:41:05Z</updated>

		<summary type="html">&lt;p&gt;Gesia: /* Introduction */ Added note about old NewGRFs using depreciated type 81&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
A callback is a special action 2 that the patch &amp;quot;calls&amp;quot; in order to modify various features, an example being the visual effect of train vehicles. &amp;amp;nbsp;See the [[ttwiki:CallbacksTut|callback tutorial]] on how to use them.&lt;br /&gt;
&lt;br /&gt;
In the final action 2 of a chain of VarAction2s, the second byte of the matching entry has to have bit 7 set to identify it as a callback result.&lt;br /&gt;
&lt;br /&gt;
For example, 04 00 is not a callback result (but it may be the ID of another chained action 2), whereas 04 80 is a callback result with a value of 4. In total a callback has 15 bit result values, where the upper 7 bits are stored in the second byte. For example, 54 C2 is a callback result with a value of 4254=16980, where again the second byte has bit 7 set, changing the 42 into C2.&lt;br /&gt;
&lt;br /&gt;
{{grfTill|7}} For GRF version 7 and below not all 15 bit values are available as return values, only values between 00 and 7EFF.&lt;br /&gt;
For compatibility with earlier patch versions, FF in the high byte is taken to mean the same thing as 80, so 04 FF also has a callback result of 4. Note that if your grf file needs to be compatible with versions before TTDPatch 2.0.1 alpha 40, you must set the high byte to FF, and so can use only 8 bit results.&lt;br /&gt;
&lt;br /&gt;
{{grfFrom|8}} For GRF version 8 and above this compatibility layer has been removed. Callbacks can return all 15 bit values between 00 and 7FFF.&lt;br /&gt;
&lt;br /&gt;
To check for a specific callback, use an [[VariationalAction2]] or [[VarAction2Advanced]] to check for variable 0C.&lt;br /&gt;
* Variable 0C contains the callback number.&lt;br /&gt;
* Variable 0C is a word, thus the VarAction2 must use type 85.&lt;br /&gt;
* Results can be specified directly using 8xxx values (see above), or with 8xxx value in subsequent (Basic/Variational/Random)Action2 which are referenced as usual with their set-id.&lt;br /&gt;
* The default case of the VarAction2 must point to the regular graphics chain, so that unknown/future callbacks results in a &amp;quot;callback failure&amp;quot; result.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;Sprite-number&amp;gt; * &amp;lt;Length&amp;gt; 02 &amp;lt;feature&amp;gt; &amp;lt;set-id&amp;gt; 85 0C 00 \wxFFFF&lt;br /&gt;
                               &amp;lt;nvar&amp;gt; (&amp;lt;set-id/result&amp;gt; \wx &amp;lt;callback&amp;gt; \wx &amp;lt;callback&amp;gt;){n}&lt;br /&gt;
                                       &amp;lt;set-id of graphics chain&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The format for VarAction2 is explained in detail on the [[VariationalAction2]] page.&lt;br /&gt;
&lt;br /&gt;
Note: Some NewGRFs still use type 81 for callbacks. However, testing callbacks with type 81 has been depreciated since 2005/2006 and should not be used. It only still works because new callback IDs were assigned in backwards-compatible way until now.&lt;br /&gt;
&lt;br /&gt;
== List of callbacks ==&lt;br /&gt;
&lt;br /&gt;
The following callbacks are defined by the patch. &amp;amp;nbsp;The number of the callback is what will be stored in variable 0C so that you can return the right results if you have several callbacks. &amp;amp;nbsp;All callbacks are explained in more detail below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;PLEASE NOTE:&#039;&#039;&#039; Since TTDPatch 2.5 beta 5, the size of variable 0C has changed, and now there are word-sized callback numbers as well. To maintain backwards compatibility, only callbacks 10..3F can be checked using a byte-sized check. Callbacks 140 and above, on the other hand, must be checked using a word or dword sized check, to make sure they are identified uniquely.&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!Number!!Feature(s)!!Meaning&lt;br /&gt;
|-&lt;br /&gt;
|10||Vehicles||[[Callback: Visual effect and wagon power|Visual effect and wagon power]]&lt;br /&gt;
|-&lt;br /&gt;
|11||Vehicles||[[Callback: Wagon length|Wagon length]]&lt;br /&gt;
|-&lt;br /&gt;
|12||Vehicles||[[Callback: Load amount|Load amount]]&lt;br /&gt;
|-&lt;br /&gt;
|13||Stations||[[Callback: Station availability|Station availability]]&lt;br /&gt;
|-&lt;br /&gt;
|14||Stations||[[Callback: Station sprite layout|Select sprite layout]]&lt;br /&gt;
|-&lt;br /&gt;
|15||Vehicles||[[Callback: Refitted capacity callback|Refitted capacity callback]]&lt;br /&gt;
|-&lt;br /&gt;
|16||Trains||[[Callback: Articulated engine|Build articulated engines]]&lt;br /&gt;
|-&lt;br /&gt;
|17||Houses||[[Callback: House construction check|House construction check]]&lt;br /&gt;
|-&lt;br /&gt;
|18||Several &amp;lt;ref name=&amp;quot;generic&amp;quot;&amp;gt;Generic callbacks are called for the feature, not any specific vehicle ID. Read the [[Action3#n-id|Action 3]] entry on how to define these.&amp;lt;/ref&amp;gt;||[[Callback: AI construction/purchase selection|AI construction/purchase selection]]&lt;br /&gt;
|-&lt;br /&gt;
|19||Vehicles||[[Callback: Cargo Subtype Display|Cargo sub-type display]]&lt;br /&gt;
|-&lt;br /&gt;
|1A||Houses||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|1B||Houses||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|1C||Houses||Construction stage changes&lt;br /&gt;
|-&lt;br /&gt;
|1D||Trains||Can wagon be attached&lt;br /&gt;
|-&lt;br /&gt;
|1E||Houses||Decide colour of building&lt;br /&gt;
|-&lt;br /&gt;
|1F||Houses||Cargo acceptance&lt;br /&gt;
|-&lt;br /&gt;
|20||Houses||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|21||Houses||Trigger building destruction&lt;br /&gt;
|-&lt;br /&gt;
|22||Industries||Availability&lt;br /&gt;
|-&lt;br /&gt;
|23||Vehicles||Additional text in purchase screen&lt;br /&gt;
|-&lt;br /&gt;
|24||Stations||Custom station layout&lt;br /&gt;
|-&lt;br /&gt;
|25||Industry tiles||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|26||Industry tiles||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|27||Industry tiles||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|28||Industries||Industry location permissibility&lt;br /&gt;
|-&lt;br /&gt;
|29||Industries||Random production change&lt;br /&gt;
|-&lt;br /&gt;
|2A||Houses||Get accepted cargo types&lt;br /&gt;
|-&lt;br /&gt;
|2B||Industry tiles||Decide cargo acceptance&lt;br /&gt;
|-&lt;br /&gt;
|2C||Industry tiles||Get accepted cargo types&lt;br /&gt;
|-&lt;br /&gt;
|2D||Vehicles||Select colour mapping for vehicle&lt;br /&gt;
|-&lt;br /&gt;
|2E||Houses||Custom cargo production&lt;br /&gt;
|-&lt;br /&gt;
|2F||Industry tiles||Custom shape check&lt;br /&gt;
|-&lt;br /&gt;
|30||Industry tiles||Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|31||Vehicles||Start/stop check&lt;br /&gt;
|-&lt;br /&gt;
|32||Vehicles||32-day callback&lt;br /&gt;
|-&lt;br /&gt;
|33||Several||Sound effect callback&lt;br /&gt;
|-&lt;br /&gt;
|34||Vehicles &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||Autoreplace vehicle selection&lt;br /&gt;
|-&lt;br /&gt;
|35||Industries||Monthly random production change&lt;br /&gt;
|-&lt;br /&gt;
|36||Vehicles||Change vehicle Properties&lt;br /&gt;
|-&lt;br /&gt;
|37||Industries||Cargo sub-type display&lt;br /&gt;
|-&lt;br /&gt;
|38||Industries||Show additional text in fund window&lt;br /&gt;
|-&lt;br /&gt;
|39||Cargoes||Custom profit calculation&lt;br /&gt;
|-&lt;br /&gt;
|3A||Industries||Show additional text in industry window&lt;br /&gt;
|-&lt;br /&gt;
|3B||Industries||Control special effects&lt;br /&gt;
|-&lt;br /&gt;
|3C||Industry tiles||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|3D||Industries||Opt out of accepting cargo&lt;br /&gt;
|-&lt;br /&gt;
|40..13F|| ||--Reserved--&lt;br /&gt;
|-&lt;br /&gt;
|140||Stations||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|141||Stations||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|142||Stations||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|143||Houses||Protect building conditionally&lt;br /&gt;
|-&lt;br /&gt;
|144||Sounds &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||{{ottdp|1.2|2.6|ottdrev=r23144|ttdprev=r821}} Ambient sound effects&lt;br /&gt;
|-&lt;br /&gt;
|145||Cargoes||Custom station rating calculation&lt;br /&gt;
|-&lt;br /&gt;
|146||New Signals &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||New signals sprite drawing&lt;br /&gt;
|-&lt;br /&gt;
|147||Canals||Add sprite offset&lt;br /&gt;
|-&lt;br /&gt;
|148||Houses||Watched cargo accepted&lt;br /&gt;
|-&lt;br /&gt;
|149||Stations||Land slope check&lt;br /&gt;
|-&lt;br /&gt;
|14A||Industries||Decide industry color&lt;br /&gt;
|-&lt;br /&gt;
|14B||Industries||Decide input cargo types&lt;br /&gt;
|-&lt;br /&gt;
|14C||Industries||Decide output cargo types&lt;br /&gt;
|-&lt;br /&gt;
|14D||Houses||Customized building name&lt;br /&gt;
|-&lt;br /&gt;
|14E||Houses||Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|14F||Houses||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|150||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|152||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Animation control&lt;br /&gt;
|-&lt;br /&gt;
|153||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Next Animation frame&lt;br /&gt;
|-&lt;br /&gt;
|154||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|155||Airports||{{ottdp|1.1|no|ottdrev=r20373}} Extra information about airport layout in the build gui&lt;br /&gt;
|-&lt;br /&gt;
|156||Airports||{{ottdp|1.1|no|ottdrev=r20373}} Airport layout name&lt;br /&gt;
|-&lt;br /&gt;
|157||Objects||Land slope check&lt;br /&gt;
|-&lt;br /&gt;
|158||Objects||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|159||Objects||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|15A||Objects||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|15B||Objects||Decide colour of building&lt;br /&gt;
|-&lt;br /&gt;
|15C||Objects||Show additional text in building window&lt;br /&gt;
|-&lt;br /&gt;
|15D||Objects||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|15E||Vehicles||{{ottdp|1.2|no|ottdrev=r23124}} Refit cost factor&lt;br /&gt;
|-&lt;br /&gt;
|15F||Industries||{{ottdp|1.3|no|ottdrev=r24186}} Set initial production level on construction&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Callback: Visual effect and wagon power}}&lt;br /&gt;
{{:Callback: Wagon length}}&lt;br /&gt;
{{:Callback: Load amount}}&lt;br /&gt;
{{:Callback: Station availability}}&lt;br /&gt;
{{:Callback: Station sprite layout}}&lt;br /&gt;
{{:Callback: Refitted capacity callback}}&lt;br /&gt;
{{:Callback: Articulated engine}}&lt;br /&gt;
{{:Callback: House construction check}}&lt;br /&gt;
{{:Callback: AI construction/purchase selection}}&lt;br /&gt;
{{:Callback: Cargo Subtype Display}}&lt;br /&gt;
{{:Callback: Next animation frame}}&lt;br /&gt;
{{:Callback: Animation control}}&lt;br /&gt;
{{:Callback: Construction stage changes}}&lt;br /&gt;
{{:Callback: Can wagon be attached}}&lt;br /&gt;
{{:Callback: Building colour}}&lt;br /&gt;
{{:Callback: Cargo acceptance}}&lt;br /&gt;
{{:Callback: Length of animation frame}}&lt;br /&gt;
{{:Callback: Trigger building destruction}}&lt;br /&gt;
{{:Callback: Industry availability}}&lt;br /&gt;
{{:Callback: Additional text in purchase screen}}&lt;br /&gt;
{{:Callback: Custom station layout}}&lt;br /&gt;
{{:Callback: Industry location permissibility}}&lt;br /&gt;
{{:Callback: Random production change}}&lt;br /&gt;
{{:Callback: Get accepted cargo types}}&lt;br /&gt;
{{:Callback: Decide cargo acceptance}}&lt;br /&gt;
{{:Callback: Select colour mapping for vehicle}}&lt;br /&gt;
{{:Callback: Custom cargo production}}&lt;br /&gt;
{{:Callback: Custom shape check}}&lt;br /&gt;
{{:Callback: Decide drawing default foundations}}&lt;br /&gt;
{{:Callback: Vehicle Start/stop check}}&lt;br /&gt;
{{:Callback: 32-day callback}}&lt;br /&gt;
{{:Callback: Sound effect}}&lt;br /&gt;
{{:Callback: Autoreplace vehicle selection}}&lt;br /&gt;
{{:Callback: Monthly random production change}}&lt;br /&gt;
{{:Callback: Change vehicle properties}}&lt;br /&gt;
{{:Callback: Cargo sub-type display for industries}}&lt;br /&gt;
{{:Callback: Show additional text in fund/building window}}&lt;br /&gt;
{{:Callback: Custom profit calculation for cargoes}}&lt;br /&gt;
{{:Callback: Show additional text in industry window}}&lt;br /&gt;
{{:Callback: Control special industry effects}}&lt;br /&gt;
{{:Callback: Disable autosloping}}&lt;br /&gt;
{{:Callback: Opt out of accepting cargo}}&lt;br /&gt;
{{:Callback: Protect building conditionally}}&lt;br /&gt;
{{:Callback: Ambient sound effects}}&lt;br /&gt;
{{:Callback: Custom station rating calculation}}&lt;br /&gt;
{{:Callback: New signals sprite drawing callback}}&lt;br /&gt;
{{:Callback: Add sprite offset callback}}&lt;br /&gt;
{{:Callback: Watched cargo accepted}}&lt;br /&gt;
{{:Callback: Station slope check}}&lt;br /&gt;
{{:Callback: Decide industry colour}}&lt;br /&gt;
{{:Callback: Decide input and output cargo types}}&lt;br /&gt;
{{:Callback: Customized building name}}&lt;br /&gt;
{{:Callback: Extra information about layout in the build gui}}&lt;br /&gt;
{{:Callback: Layout name}}&lt;br /&gt;
{{:Callback: Object slope check}}&lt;br /&gt;
{{:Callback: Decide object colour}}&lt;br /&gt;
{{:Callback: Refit cost factor}}&lt;br /&gt;
{{:Callback: Set initial production level on construction}}&lt;/div&gt;</summary>
		<author><name>Gesia</name></author>
	</entry>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=Talk:Callbacks&amp;diff=3452</id>
		<title>Talk:Callbacks</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=Talk:Callbacks&amp;diff=3452"/>
		<updated>2013-10-17T21:48:38Z</updated>

		<summary type="html">&lt;p&gt;Gesia: Discussion started for &amp;quot;callbacks&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Gesia|Gesia]] ([[User talk:Gesia|talk]]) 21:48, 17 October 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
The new introduction states that variable 1C is a word and therefore type 85 must be used. &lt;br /&gt;
&lt;br /&gt;
However, the paragraph below mentions variable 0C and some GRFs (e.g. Ikarus 6) use type 81, which seems to work ingame:&lt;br /&gt;
&lt;br /&gt;
   81 * 9	 02 01 02 01 01 00 00 00 00&lt;br /&gt;
   82 * 14	 02 01 10 &#039;&#039;&#039;&#039;&#039;81 0C&#039;&#039;&#039;&#039;&#039; 00 FF 01 02 FF 23 23 02 00&lt;br /&gt;
   83 * 7	 00 01 01 01 02 0E FF&lt;br /&gt;
   84 * 10	 03 01 01 02 01 FF 10 00 A1 00&lt;br /&gt;
&lt;br /&gt;
I&#039;m guessing some relevant information is still missing?&lt;/div&gt;</summary>
		<author><name>Gesia</name></author>
	</entry>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=Callback:_Additional_text_in_purchase_screen&amp;diff=3449</id>
		<title>Callback: Additional text in purchase screen</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=Callback:_Additional_text_in_purchase_screen&amp;diff=3449"/>
		<updated>2013-10-16T18:03:50Z</updated>

		<summary type="html">&lt;p&gt;Gesia: /* Additional text in purchase screen (23) */ Example added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Additional text in purchase screen (23) ==&lt;br /&gt;
&lt;br /&gt;
This callback can be used to append text below the vehicle information in the purchase screen. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it.&lt;br /&gt;
&lt;br /&gt;
A text string for feature 48 in the D0XX range must be defined before using this callback. Line breaks (0D) and colors are supported. The return value of this callback is the XX of a D0XX string ID. &lt;br /&gt;
&lt;br /&gt;
As of r1908, text IDs D100..D3FF may also be returned.&lt;br /&gt;
&lt;br /&gt;
Lines are wrapped automatically, or may be broken explicitly using the newline character 0D. How many lines are available depends on the type of vehicle and its other properties, for instance the presence or absence of a &amp;quot;refittable to&amp;quot; line or powered wagons etc. &lt;br /&gt;
&lt;br /&gt;
If cargo FF (buy menu sprite) is handled explicitly for a vehicle, then the varaction 2 handling [[Callbacks#Additional text in purchase screen (23) |callback 23]] must be in the buy menu varaction 2 chain.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example for setting additional text for a road vehicle:&lt;br /&gt;
&lt;br /&gt;
 // Define string with ID D001. Bit 7 of the language byte must be set to 1, because the string ID is a word.&lt;br /&gt;
 4 * 32 04 48 83 01 01 D0 &amp;quot;Hint: This is a &amp;quot; 0D &amp;quot;new line.&amp;quot; 00&lt;br /&gt;
 // The callback&lt;br /&gt;
 5 * 14 02 01 10 81 0C 00 FF 01 01 80 23 23 02 00&lt;br /&gt;
&lt;br /&gt;
{{grfFrom|8}} Since GRF version 8 the value 400 can be returned to display no text. In older versions it is necessary to fail the callback.&lt;br /&gt;
&lt;br /&gt;
{{ottdp|1.2|no|ottdrev=r23045}} Since OpenTTD r23045 the contents of registers 100h..105h are copied onto the text reference stack.&lt;br /&gt;
&lt;br /&gt;
[[Category:Callbacks]]&lt;/div&gt;</summary>
		<author><name>Gesia</name></author>
	</entry>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=Callbacks&amp;diff=3448</id>
		<title>Callbacks</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=Callbacks&amp;diff=3448"/>
		<updated>2013-10-16T17:43:22Z</updated>

		<summary type="html">&lt;p&gt;Gesia: /* Format: */ Added section about callback format, because I missed it very much while trying to get the grasp of it.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
A callback is a special action 2 that the patch &amp;quot;calls&amp;quot; in order to modify various features, an example being the visual effect of train vehicles. &amp;amp;nbsp;See the [[ttwiki:CallbacksTut|callback tutorial]] on how to use them.&lt;br /&gt;
&lt;br /&gt;
In the final action 2 of a chain of VarAction2s, the second byte of the matching entry has to have bit 7 set to identify it as a callback result.&lt;br /&gt;
&lt;br /&gt;
For example, 04 00 is not a callback result (but it may be the ID of another chained action 2), whereas 04 80 is a callback result with a value of 4. In total a callback has 15 bit result values, where the upper 7 bits are stored in the second byte. For example, 54 C2 is a callback result with a value of 4254=16980, where again the second byte has bit 7 set, changing the 42 into C2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Format ==&lt;br /&gt;
&lt;br /&gt;
A callback has the same format as a VarAction2 with some values used in a different way:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;Sprite-number&amp;gt; * &amp;lt;Length&amp;gt; 02 &amp;lt;feature&amp;gt; &amp;lt;set-id&amp;gt; &amp;lt;type&amp;gt; 1C &amp;lt;varadjust&amp;gt; &amp;lt;nvar&amp;gt; (&amp;lt;value&amp;gt; &amp;lt;callback&amp;gt; &amp;lt;callback&amp;gt;){n} &amp;lt;default&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!&#039;&#039;&#039;Element&#039;&#039;&#039;!![[GRFActionsDetailed|&#039;&#039;&#039;Size&#039;&#039;&#039;]]!!&#039;&#039;&#039;Description&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;Sprite-number&amp;gt;||dec||A sequential sprite number&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;length&amp;gt;||dec||The total number of bytes used in this action.&lt;br /&gt;
|-&lt;br /&gt;
|02||B||Defines action 02&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;feature&amp;gt;||B||For what type of vehicle/station should this definition be used?&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;set-id&amp;gt;||B||The ID of this action 2 (used like a cargo ID)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;type&amp;gt;||B||Size definition, 81 for Byte, 85 for Word, 89 for DWord&lt;br /&gt;
|-&lt;br /&gt;
|1C||B||The callback variable&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;varadjust&amp;gt;||V||How to manipulate the value before deciding.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nvar&amp;gt;||B||Number of callbacks&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;value&amp;gt;||W||The return value, with bit 15 set to 1 to indicate a callback result.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;callback&amp;gt;||B/W/D||The callback code, must be repeated to comply with the format of VarAction2.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;default&amp;gt;||W||00 00, &amp;lt;set-it&amp;gt; 00, or something else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The size of &amp;lt;varadjust&amp;gt; depends on &amp;lt;type&amp;gt; as well as the adjustments to be performed and must always provide an AND mask. For &amp;lt;type&amp;gt; 81, a &amp;quot;do nothing&amp;quot; &amp;lt;varadjust&amp;gt; would be 00 FF. See VarAction2 for details.&lt;br /&gt;
&lt;br /&gt;
You repeat the sequence of &amp;lt;value&amp;gt; &amp;lt;callback&amp;gt; &amp;lt;callback&amp;gt; as often as &amp;lt;nvar&amp;gt; specifies.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;callback&amp;gt; has a size of B, W, or D, depending on &amp;lt;type&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{grfTill|7}} For GRF version 7 and below not all 15 bit values are available as return values, only values between 00 and 7EFF.&lt;br /&gt;
For compatibility with earlier patch versions, FF in the high byte is taken to mean the same thing as 80, so 04 FF also has a callback result of 4. Note that if your grf file needs to be compatible with versions before TTDPatch 2.0.1 alpha 40, you must set the high byte to FF, and so can use only 8 bit results.&lt;br /&gt;
&lt;br /&gt;
{{grfFrom|8}} For GRF version 8 and above this compatibility layer has been removed. Callbacks can return all 15 bit values between 00 and 7FFF.&lt;br /&gt;
&lt;br /&gt;
== List of callbacks ==&lt;br /&gt;
&lt;br /&gt;
The following callbacks are defined by the patch. &amp;amp;nbsp;The number of the callback is what will be stored in variable 0C so that you can return the right results if you have several callbacks. &amp;amp;nbsp;All callbacks are explained in more detail below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;PLEASE NOTE:&#039;&#039;&#039; Since TTDPatch 2.5 beta 5, the size of variable 0C has changed, and now there are word-sized callback numbers as well. To maintain backwards compatibility, only callbacks 10..3F can be checked using a byte-sized check. Callbacks 140 and above, on the other hand, must be checked using a word or dword sized check, to make sure they are identified uniquely.&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!Number!!Feature(s)!!Meaning&lt;br /&gt;
|-&lt;br /&gt;
|10||Vehicles||[[Callback: Visual effect and wagon power|Visual effect and wagon power]]&lt;br /&gt;
|-&lt;br /&gt;
|11||Vehicles||[[Callback: Wagon length|Wagon length]]&lt;br /&gt;
|-&lt;br /&gt;
|12||Vehicles||[[Callback: Load amount|Load amount]]&lt;br /&gt;
|-&lt;br /&gt;
|13||Stations||[[Callback: Station availability|Station availability]]&lt;br /&gt;
|-&lt;br /&gt;
|14||Stations||[[Callback: Station sprite layout|Select sprite layout]]&lt;br /&gt;
|-&lt;br /&gt;
|15||Vehicles||[[Callback: Refitted capacity callback|Refitted capacity callback]]&lt;br /&gt;
|-&lt;br /&gt;
|16||Trains||[[Callback: Articulated engine|Build articulated engines]]&lt;br /&gt;
|-&lt;br /&gt;
|17||Houses||[[Callback: House construction check|House construction check]]&lt;br /&gt;
|-&lt;br /&gt;
|18||Several &amp;lt;ref name=&amp;quot;generic&amp;quot;&amp;gt;Generic callbacks are called for the feature, not any specific vehicle ID. Read the [[Action3#n-id|Action 3]] entry on how to define these.&amp;lt;/ref&amp;gt;||[[Callback: AI construction/purchase selection|AI construction/purchase selection]]&lt;br /&gt;
|-&lt;br /&gt;
|19||Vehicles||[[Callback: Cargo Subtype Display|Cargo sub-type display]]&lt;br /&gt;
|-&lt;br /&gt;
|1A||Houses||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|1B||Houses||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|1C||Houses||Construction stage changes&lt;br /&gt;
|-&lt;br /&gt;
|1D||Trains||Can wagon be attached&lt;br /&gt;
|-&lt;br /&gt;
|1E||Houses||Decide colour of building&lt;br /&gt;
|-&lt;br /&gt;
|1F||Houses||Cargo acceptance&lt;br /&gt;
|-&lt;br /&gt;
|20||Houses||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|21||Houses||Trigger building destruction&lt;br /&gt;
|-&lt;br /&gt;
|22||Industries||Availability&lt;br /&gt;
|-&lt;br /&gt;
|23||Vehicles||Additional text in purchase screen&lt;br /&gt;
|-&lt;br /&gt;
|24||Stations||Custom station layout&lt;br /&gt;
|-&lt;br /&gt;
|25||Industry tiles||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|26||Industry tiles||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|27||Industry tiles||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|28||Industries||Industry location permissibility&lt;br /&gt;
|-&lt;br /&gt;
|29||Industries||Random production change&lt;br /&gt;
|-&lt;br /&gt;
|2A||Houses||Get accepted cargo types&lt;br /&gt;
|-&lt;br /&gt;
|2B||Industry tiles||Decide cargo acceptance&lt;br /&gt;
|-&lt;br /&gt;
|2C||Industry tiles||Get accepted cargo types&lt;br /&gt;
|-&lt;br /&gt;
|2D||Vehicles||Select colour mapping for vehicle&lt;br /&gt;
|-&lt;br /&gt;
|2E||Houses||Custom cargo production&lt;br /&gt;
|-&lt;br /&gt;
|2F||Industry tiles||Custom shape check&lt;br /&gt;
|-&lt;br /&gt;
|30||Industry tiles||Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|31||Vehicles||Start/stop check&lt;br /&gt;
|-&lt;br /&gt;
|32||Vehicles||32-day callback&lt;br /&gt;
|-&lt;br /&gt;
|33||Several||Sound effect callback&lt;br /&gt;
|-&lt;br /&gt;
|34||Vehicles &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||Autoreplace vehicle selection&lt;br /&gt;
|-&lt;br /&gt;
|35||Industries||Monthly random production change&lt;br /&gt;
|-&lt;br /&gt;
|36||Vehicles||Change vehicle Properties&lt;br /&gt;
|-&lt;br /&gt;
|37||Industries||Cargo sub-type display&lt;br /&gt;
|-&lt;br /&gt;
|38||Industries||Show additional text in fund window&lt;br /&gt;
|-&lt;br /&gt;
|39||Cargoes||Custom profit calculation&lt;br /&gt;
|-&lt;br /&gt;
|3A||Industries||Show additional text in industry window&lt;br /&gt;
|-&lt;br /&gt;
|3B||Industries||Control special effects&lt;br /&gt;
|-&lt;br /&gt;
|3C||Industry tiles||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|3D||Industries||Opt out of accepting cargo&lt;br /&gt;
|-&lt;br /&gt;
|40..13F|| ||--Reserved--&lt;br /&gt;
|-&lt;br /&gt;
|140||Stations||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|141||Stations||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|142||Stations||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|143||Houses||Protect building conditionally&lt;br /&gt;
|-&lt;br /&gt;
|144||Sounds &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||{{ottdp|1.2|2.6|ottdrev=r23144|ttdprev=r821}} Ambient sound effects&lt;br /&gt;
|-&lt;br /&gt;
|145||Cargoes||Custom station rating calculation&lt;br /&gt;
|-&lt;br /&gt;
|146||New Signals &amp;lt;ref name=&amp;quot;generic&amp;quot;/&amp;gt;||New signals sprite drawing&lt;br /&gt;
|-&lt;br /&gt;
|147||Canals||Add sprite offset&lt;br /&gt;
|-&lt;br /&gt;
|148||Houses||Watched cargo accepted&lt;br /&gt;
|-&lt;br /&gt;
|149||Stations||Land slope check&lt;br /&gt;
|-&lt;br /&gt;
|14A||Industries||Decide industry color&lt;br /&gt;
|-&lt;br /&gt;
|14B||Industries||Decide input cargo types&lt;br /&gt;
|-&lt;br /&gt;
|14C||Industries||Decide output cargo types&lt;br /&gt;
|-&lt;br /&gt;
|14D||Houses||Customized building name&lt;br /&gt;
|-&lt;br /&gt;
|14E||Houses||Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|14F||Houses||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|150||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Decide drawing default foundations&lt;br /&gt;
|-&lt;br /&gt;
|152||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Animation control&lt;br /&gt;
|-&lt;br /&gt;
|153||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Next Animation frame&lt;br /&gt;
|-&lt;br /&gt;
|154||Airport tiles||{{ottdp|1.1|no|ottdrev=r19197}} Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|155||Airports||{{ottdp|1.1|no|ottdrev=r20373}} Extra information about airport layout in the build gui&lt;br /&gt;
|-&lt;br /&gt;
|156||Airports||{{ottdp|1.1|no|ottdrev=r20373}} Airport layout name&lt;br /&gt;
|-&lt;br /&gt;
|157||Objects||Land slope check&lt;br /&gt;
|-&lt;br /&gt;
|158||Objects||Next animation frame&lt;br /&gt;
|-&lt;br /&gt;
|159||Objects||Animation control&lt;br /&gt;
|-&lt;br /&gt;
|15A||Objects||Length of animation frame&lt;br /&gt;
|-&lt;br /&gt;
|15B||Objects||Decide colour of building&lt;br /&gt;
|-&lt;br /&gt;
|15C||Objects||Show additional text in building window&lt;br /&gt;
|-&lt;br /&gt;
|15D||Objects||Disable autosloping&lt;br /&gt;
|-&lt;br /&gt;
|15E||Vehicles||{{ottdp|1.2|no|ottdrev=r23124}} Refit cost factor&lt;br /&gt;
|-&lt;br /&gt;
|15F||Industries||{{ottdp|1.3|no|ottdrev=r24186}} Set initial production level on construction&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{:Callback: Visual effect and wagon power}}&lt;br /&gt;
{{:Callback: Wagon length}}&lt;br /&gt;
{{:Callback: Load amount}}&lt;br /&gt;
{{:Callback: Station availability}}&lt;br /&gt;
{{:Callback: Station sprite layout}}&lt;br /&gt;
{{:Callback: Refitted capacity callback}}&lt;br /&gt;
{{:Callback: Articulated engine}}&lt;br /&gt;
{{:Callback: House construction check}}&lt;br /&gt;
{{:Callback: AI construction/purchase selection}}&lt;br /&gt;
{{:Callback: Cargo Subtype Display}}&lt;br /&gt;
{{:Callback: Next animation frame}}&lt;br /&gt;
{{:Callback: Animation control}}&lt;br /&gt;
{{:Callback: Construction stage changes}}&lt;br /&gt;
{{:Callback: Can wagon be attached}}&lt;br /&gt;
{{:Callback: Building colour}}&lt;br /&gt;
{{:Callback: Cargo acceptance}}&lt;br /&gt;
{{:Callback: Length of animation frame}}&lt;br /&gt;
{{:Callback: Trigger building destruction}}&lt;br /&gt;
{{:Callback: Industry availability}}&lt;br /&gt;
{{:Callback: Additional text in purchase screen}}&lt;br /&gt;
{{:Callback: Custom station layout}}&lt;br /&gt;
{{:Callback: Industry location permissibility}}&lt;br /&gt;
{{:Callback: Random production change}}&lt;br /&gt;
{{:Callback: Get accepted cargo types}}&lt;br /&gt;
{{:Callback: Decide cargo acceptance}}&lt;br /&gt;
{{:Callback: Select colour mapping for vehicle}}&lt;br /&gt;
{{:Callback: Custom cargo production}}&lt;br /&gt;
{{:Callback: Custom shape check}}&lt;br /&gt;
{{:Callback: Decide drawing default foundations}}&lt;br /&gt;
{{:Callback: Vehicle Start/stop check}}&lt;br /&gt;
{{:Callback: 32-day callback}}&lt;br /&gt;
{{:Callback: Sound effect}}&lt;br /&gt;
{{:Callback: Autoreplace vehicle selection}}&lt;br /&gt;
{{:Callback: Monthly random production change}}&lt;br /&gt;
{{:Callback: Change vehicle properties}}&lt;br /&gt;
{{:Callback: Cargo sub-type display for industries}}&lt;br /&gt;
{{:Callback: Show additional text in fund/building window}}&lt;br /&gt;
{{:Callback: Custom profit calculation for cargoes}}&lt;br /&gt;
{{:Callback: Show additional text in industry window}}&lt;br /&gt;
{{:Callback: Control special industry effects}}&lt;br /&gt;
{{:Callback: Disable autosloping}}&lt;br /&gt;
{{:Callback: Opt out of accepting cargo}}&lt;br /&gt;
{{:Callback: Protect building conditionally}}&lt;br /&gt;
{{:Callback: Ambient sound effects}}&lt;br /&gt;
{{:Callback: Custom station rating calculation}}&lt;br /&gt;
{{:Callback: New signals sprite drawing callback}}&lt;br /&gt;
{{:Callback: Add sprite offset callback}}&lt;br /&gt;
{{:Callback: Watched cargo accepted}}&lt;br /&gt;
{{:Callback: Station slope check}}&lt;br /&gt;
{{:Callback: Decide industry colour}}&lt;br /&gt;
{{:Callback: Decide input and output cargo types}}&lt;br /&gt;
{{:Callback: Customized building name}}&lt;br /&gt;
{{:Callback: Extra information about layout in the build gui}}&lt;br /&gt;
{{:Callback: Layout name}}&lt;br /&gt;
{{:Callback: Object slope check}}&lt;br /&gt;
{{:Callback: Decide object colour}}&lt;br /&gt;
{{:Callback: Refit cost factor}}&lt;br /&gt;
{{:Callback: Set initial production level on construction}}&lt;/div&gt;</summary>
		<author><name>Gesia</name></author>
	</entry>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=VariationalAction2&amp;diff=3447</id>
		<title>VariationalAction2</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=VariationalAction2&amp;diff=3447"/>
		<updated>2013-10-16T15:15:17Z</updated>

		<summary type="html">&lt;p&gt;Gesia: /* Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
To support changes in graphics based on other factors than just the load states, you use a VarAction2. This provides a sophisticated way of deciding what graphics to use.&lt;br /&gt;
&lt;br /&gt;
A VarAction2 can be used like any other action 2, but it provides an additional step in-between: instead of defining the action 1 sets right away, it instead specifies a list of additional action 2 entry, one of which is used depending on the kind of variation that is defined. These action 2 entries that are referred can in turn be variational or random (to provide chains of decisions), or they can be the final element, that is a regular action 2 which contains definitions of action 1 sets, or a callback result.&lt;br /&gt;
&lt;br /&gt;
== Format ==&lt;br /&gt;
&lt;br /&gt;
The data looks as follows:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;Sprite-number&amp;gt; * &amp;lt;Length&amp;gt; 02 &amp;lt;feature&amp;gt; &amp;lt;set-id&amp;gt; &amp;lt;type&amp;gt; &amp;lt;variable&amp;gt; &amp;lt;varadjust&amp;gt; &amp;lt;nvar&amp;gt; (&amp;lt;set-id&amp;gt; &amp;lt;low-range&amp;gt; &amp;lt;high-range&amp;gt;){n} &amp;lt;default&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!&#039;&#039;&#039;Element&#039;&#039;&#039;!![[GRFActionsDetailed|&#039;&#039;&#039;Size&#039;&#039;&#039;]]!!&#039;&#039;&#039;Description&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;Sprite-number&amp;gt;||dec||A sequential sprite number&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;length&amp;gt;||dec||The total number of bytes used in this action.&lt;br /&gt;
|-&lt;br /&gt;
|02||B||Defines action 02&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;feature&amp;gt;||B||For what type of vehicle/station should this definition be used?&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;set-id&amp;gt;||B||The ID of this action 2 (used like a cargo ID)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;type&amp;gt;||B||Type of VarAction2, see below&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;variable&amp;gt;||B||Which variable we base the decision on&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;varadjust&amp;gt;||V||How to manipulate the value before deciding.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nvar&amp;gt;||B||Number of different ranges of the value (not counting the default)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;set-id&amp;gt;||W||Action 2 set-id to use for the following range.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;low-range&amp;gt;||B/W/D||Minimum (inclusive) of the range for which to use the above set-id&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;high-range&amp;gt;||B/W/D||Maximum (inclusive) of the range&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;default&amp;gt;||W||Action 2 set-id to use if no range matches&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The size of &amp;lt;varadjust&amp;gt; depends on &amp;lt;type&amp;gt; as well as the adjustments to be performed and must always provide an AND mask. For &amp;lt;type&amp;gt; 81, a &amp;quot;do nothing&amp;quot; &amp;lt;varadjust&amp;gt; would be 00 FF.&lt;br /&gt;
&lt;br /&gt;
You repeat the sequence of &amp;lt;set-id&amp;gt; &amp;lt;low-range&amp;gt; &amp;lt;high-range&amp;gt; as often as &amp;lt;nvar&amp;gt; specifies.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;low-range&amp;gt; and &amp;lt;high-range&amp;gt; have a size of B, W, or D, depending on &amp;lt;type&amp;gt;. See that entry for more information.&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
=== Sprite-number ===&lt;br /&gt;
&lt;br /&gt;
This is just the number you are at.&lt;br /&gt;
&lt;br /&gt;
=== Length ===&lt;br /&gt;
&lt;br /&gt;
Count the number of bytes in this action.&lt;br /&gt;
&lt;br /&gt;
=== Feature ===&lt;br /&gt;
&lt;br /&gt;
This sets the type of [[Features|feature]] that you wish to change. Set it to:&lt;br /&gt;
&lt;br /&gt;
{|- |&lt;br /&gt;
!Value!![[Features|Feature]]&lt;br /&gt;
|-&lt;br /&gt;
|00||[[VariationalAction2/Vehicles | Trains]]&lt;br /&gt;
|-&lt;br /&gt;
|01||[[VariationalAction2/Vehicles | Road Vehicles]]&lt;br /&gt;
|-&lt;br /&gt;
|02||[[VariationalAction2/Vehicles | Ships]]&lt;br /&gt;
|-&lt;br /&gt;
|03||[[VariationalAction2/Vehicles | Aircraft]]&lt;br /&gt;
|-&lt;br /&gt;
|04||[[VariationalAction2/Stations | Stations]]&lt;br /&gt;
|-&lt;br /&gt;
|05||[[VariationalAction2/Canals | Canals/Rivers]]&lt;br /&gt;
|-&lt;br /&gt;
|06||[[VariationalAction2/Bridges | Bridges]]&lt;br /&gt;
|-&lt;br /&gt;
|07||[[VariationalAction2/Houses | Houses]]&lt;br /&gt;
|-&lt;br /&gt;
|09||[[VariationalAction2/Industry Tiles | Industry Tiles]]&lt;br /&gt;
|-&lt;br /&gt;
|0A||[[VariationalAction2/Industries | Industries]]&lt;br /&gt;
|-&lt;br /&gt;
|0B||Cargos (no feature specific variables)&lt;br /&gt;
|-&lt;br /&gt;
|0C||Sound Effects (no feature specific variables)&lt;br /&gt;
|-&lt;br /&gt;
|0D||[[VariationalAction2/Airports | Airports]]&lt;br /&gt;
|-&lt;br /&gt;
|0E||[[VariationalAction2/Signals | Signals]]&lt;br /&gt;
|-&lt;br /&gt;
|0F||[[VariationalAction2/Objects | Objects]]&lt;br /&gt;
|-&lt;br /&gt;
|10||[[VariationalAction2/Railtypes | Railtypes]]&lt;br /&gt;
|-&lt;br /&gt;
|11||[[VariationalAction2/Airport Tiles | Airport Tiles]]&lt;br /&gt;
|-&lt;br /&gt;
|12||[[VariationalAction2/Towns | Towns]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Set-ID ===&lt;br /&gt;
&lt;br /&gt;
This defines the number of this action 2. &amp;amp;nbsp;The ID can then be used as target in an action 3 or another variational/random action 2.&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
! !! B&amp;lt;br/&amp;gt;Access lowest byte !! {{ottdp|0.6|2.5}} W&amp;lt;br/&amp;gt;Access lowest word !! {{ottdp|0.6|2.5}} D&amp;lt;br/&amp;gt;Access lowest doubleword&lt;br /&gt;
|-&lt;br /&gt;
!align=&amp;quot;left&amp;quot;| Access general variable or&amp;lt;br/&amp;gt;variable of the primary object&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| 81 &lt;br /&gt;
|align=&amp;quot;center&amp;quot;| 85 &lt;br /&gt;
|align=&amp;quot;center&amp;quot;| 89&lt;br /&gt;
|-&lt;br /&gt;
!align=&amp;quot;left&amp;quot;| Access variable of &amp;quot;related&amp;quot; object&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| 82 &lt;br /&gt;
|align=&amp;quot;center&amp;quot;| 86 &lt;br /&gt;
|align=&amp;quot;center&amp;quot;| 8A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The access type specifies both the size of the variable access, and selects between general variables and the object&#039;s innate variables, or variables of a specific &amp;quot;related&amp;quot; object.&lt;br /&gt;
&lt;br /&gt;
{|- |&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|[[Features|Feature]]!!Related object&lt;br /&gt;
|-&lt;br /&gt;
|00-03||[[VariationalAction2/Vehicles | Vehicles]]||First [[VariationalAction2/Vehicles | vehicle]] of consist&lt;br /&gt;
|-&lt;br /&gt;
|04||[[VariationalAction2/Stations | Stations]]||[[VariationalAction2/Towns | Town]] to which station belongs&lt;br /&gt;
|-&lt;br /&gt;
|05||[[VariationalAction2/Canals | Canals/Rivers]]||N/A&lt;br /&gt;
|-&lt;br /&gt;
|06||[[VariationalAction2/Bridges | Bridges]]||[[VariationalAction2/Towns | Town]] of bridge&lt;br /&gt;
|-&lt;br /&gt;
|07||[[VariationalAction2/Houses | Houses]]||[[VariationalAction2/Towns | Town]] of house&lt;br /&gt;
|-&lt;br /&gt;
|09||[[VariationalAction2/Industry Tiles | Industry Tiles]]||[[VariationalAction2/Industries | Industry]] containing tile&lt;br /&gt;
|-&lt;br /&gt;
|0A||[[VariationalAction2/Industries | Industries]]||[[VariationalAction2/Towns | Town]] of industry&lt;br /&gt;
|-&lt;br /&gt;
|0B||Cargos||N/A&lt;br /&gt;
|-&lt;br /&gt;
|0C||Sound Effects||N/A&lt;br /&gt;
|-&lt;br /&gt;
|0D||[[VariationalAction2/Airports | Airports]]||N/A&lt;br /&gt;
|-&lt;br /&gt;
|0E||[[VariationalAction2/Signals | Signals]]||N/A&lt;br /&gt;
|-&lt;br /&gt;
|0F||[[VariationalAction2/Objects | Objects]]||[[VariationalAction2/Towns | Town]] of object&lt;br /&gt;
|-&lt;br /&gt;
|10||[[VariationalAction2/Railtypes | Railtypes]]||N/A&lt;br /&gt;
|-&lt;br /&gt;
|11||[[VariationalAction2/Airport Tiles | Airport Tiles]]||N/A&lt;br /&gt;
|-&lt;br /&gt;
|12||[[VariationalAction2/Towns | Towns]]||N/A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Every variable specifies a size for it. Not every variable is a doubleword.&lt;br /&gt;
If the accessed variable is smaller than the size given here, the extra bits may contain junk, and should be &amp;lt;and-masked&amp;gt; out.&lt;br /&gt;
&lt;br /&gt;
=== Variable ===&lt;br /&gt;
&lt;br /&gt;
Variational Action 2 allows accessing these variables:&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!&#039;&#039;&#039;Number&#039;&#039;&#039;!![[GRFActionsDetailed|&#039;&#039;&#039;Size&#039;&#039;&#039;]]!!Version!!&#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|00-3F|| || ||See [[GlobalVariables| global variables page]].&lt;br /&gt;
|-&lt;br /&gt;
|40+x||D|| ||specially calculated feature-specific variable, see following feature-specific pages&lt;br /&gt;
|-&lt;br /&gt;
|5F||D||{{ottdp|0.7|2.6|ttdprev=r1928}}||Feature-specific random data: triggers in low byte, bits in other three bytes. Bits of the variable not associated with random or trigger bits are reserved.&lt;br /&gt;
|-&lt;br /&gt;
|60+x||D|| ||similar to 40+x variables, but the variable number must be followed by a byte, which will be given to the variable handler as parameter.&lt;br /&gt;
|-&lt;br /&gt;
|7B||-||{{ottdp|1.1|2.6|ottdrev=r21604|ttdprev=r2359}}||A special 60+x variable to be used in Advanced Variational Action 2. It allows to evaluate any other 60+x variable using a non-constant parameter from a register. The parameter of variable 7B specifies another 60+x variable which is evaluated. The parameter for that variable is read from the accumulator (&#039;val1&#039;), i.e. the result from the preceding operations of the same Advanced Variational Action 2. Hence variable 7B may not be the first variable used in the calculation. Variable 7B itself and 7E (procedure call) are not allowed to be used as parameter for variable 7B.&lt;br /&gt;
&lt;br /&gt;
{{ottdp|1.2|no|ottdrev=r23138}} Since OpenTTD r23138 you can use this to pass 32 bit parameters to 60+x variables. Currently this is only useful for a few variables, e.g. vehicle variable 60. For most variables the higher bits of the parameter are considered reserved. So, make sure to mask the higher bits in the preceding calculations.&lt;br /&gt;
|-&lt;br /&gt;
|7C||D||{{ottdp|0.6|2.6|ttdprev=r1315}}||A special 60+x variable used to access values stored in the registers of [[Storages#Persistent storage|persistent storage]].&lt;br /&gt;
|-&lt;br /&gt;
|7D||D||{{ottdp|0.6|2.6|ttdprev=r1246}}||A special 60+x variable used to access values stored in the registers of [[Storages#Temporary storage|temporary storage]]. Available in the purchase list.&lt;br /&gt;
|-&lt;br /&gt;
|7E||D||{{ottdp|0.6|2.5}}||A special 60+x variable indicating a [[VarAction2Advanced#Using procedures|procedure call]]. Available in the purchase list.&lt;br /&gt;
|-&lt;br /&gt;
|7F||D||{{ottdp|0.6|2.5}}||A special 60+x variable that reads GRF parameter whose number is given by the 60+x parameter. Available in the purchase list.&lt;br /&gt;
|-&lt;br /&gt;
|80+x|| || ||Feature-specific variable, see following feature-specific pages. While most of these variables actually refer to raw memory locations of original TTD structures, you cannot rely on that. Some variables were added later, some were moved or replaced. Only the variables listed in the specs are somewhat set to not be changed in the future.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For all features, the 80+x variables are offsets into the corresponding structure in TTD&#039;s game data. &amp;amp;nbsp;The 40+x and 60+x variables are special variables that are computed on-the-fly, and aren&#039;t actually stored anywhere in memory, unless stated otherwise. Therefore they should be used as little as necessary so as not to slow down the game too much with the calculation of these variables (which can be called thousands of times per second, whenever any vehicle moves).&lt;br /&gt;
&lt;br /&gt;
When displaying a vehicle (etc.) in the purchase list, the game will show those variations based on external variables (dates etc.) correctly, but variations based on vehicle variables (variables 40+x, 60+x and 80+x) will always show the first (not the default) cargo-ID unless otherwise specified for the given variable. If you do a calculation, the first cargo-ID will be selected if any of the needed variables is inaccessible.&lt;br /&gt;
&lt;br /&gt;
The lists of 80+x variables on the following pages are not exhaustive; only the useful variables are listed there. For a full list check the definition of corresponding structures in TTD. Marcin Grzegorczyk has a pretty good list of the structure definitions on his [http://marcin.ttdpatch.net/sv1codec/TTD-locations.html savegame internals page].&lt;br /&gt;
&lt;br /&gt;
=== varadjust ===&lt;br /&gt;
&lt;br /&gt;
Adjust variable to a more useful range. It has the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;  &amp;lt;shift-num&amp;gt; &amp;lt;and-mask&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;add-val&amp;gt; &amp;lt;divide-val&amp;gt;/&amp;lt;modulo-val&amp;gt;]&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!&#039;&#039;&#039;Element&#039;&#039;&#039;!![[GRFActionsDetailed|&#039;&#039;&#039;Size&#039;&#039;&#039;]]!!&#039;&#039;&#039;Description&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|shift-num||B||value to right-shift the variable, and some special bits. See below.&lt;br /&gt;
|-&lt;br /&gt;
|and-mask||B/W/D||value with which to AND the variable after shifting. Return this value if neither bit 6 nor bit 7 of shift-num are set.&lt;br /&gt;
|-&lt;br /&gt;
|add-val||B/W/D||value to add to the variable after ANDing. Only present if bits 6 or 7 are set in shift-num.&lt;br /&gt;
|-&lt;br /&gt;
|divide-val||B/W/D||return the sum divided by this value. Only present if bit 6 is set in shift-num.&lt;br /&gt;
|-&lt;br /&gt;
|modulo-val||B/W/D||return the sum modulo (remainder of division by) this value. Only present if bit 7 is set in shift-num.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;shift-num&amp;gt; is a partial bit-mask; its bits have the following meanings:&lt;br /&gt;
&lt;br /&gt;
{| |-&lt;br /&gt;
!Bit(s)!!Value!!Version!!Meaning&lt;br /&gt;
|-&lt;br /&gt;
|0..4||0..1F||{{ottdp|0.6|2.0}}||number of bits to right shift &amp;lt;variable&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|5||20||{{ottdp|0.6|2.5}}||This is an [[VarAction2Advanced|advanced VarAction2]]&lt;br /&gt;
|-&lt;br /&gt;
|6||40||{{ottdp|0.6|2.5}}||This is a shift-and-add-divide adjustment.&lt;br /&gt;
|-&lt;br /&gt;
|7||80||{{ottdp|0.6|2.5}}||This is a shift-and-add-modulo adjustment.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Bits 6 and 7 may not both be set. If neither are set, this varadjust is a shift-and adjustment.&lt;br /&gt;
&lt;br /&gt;
Note that for the add and divide operations, both the variable and the divisor are taken to be signed numbers. This means that if the high bit is set, the number is taken to be negative, so you may need to mask out the most significant bit to do an unsigned division.&lt;br /&gt;
&lt;br /&gt;
=== nvar ===&lt;br /&gt;
&lt;br /&gt;
Here you set how many different ranges to check for. If the value of the variable, after the above manipulations, is not within one of these ranges, the default will be used. &amp;amp;nbsp;When displayed in the purchase window, the game will always show the first range if the variable is of the 40+x or 80+x type (because the variable is undefined since the vehicle doesn&#039;t exist yet).&lt;br /&gt;
&lt;br /&gt;
{{ottdp|0.6|2.5|ttdprev=2.0.1 alpha 57}} Since TTDPatch 2.0.1 alpha 57, nvar=0 is a special case. Instead of using ranges, nvar=0 means that the result of an [[VarAction2Advanced|advanced]] calculation (or, if no calculation is performed, the adjusted variable value itself) is returned as callback result, with bit 15 set. &amp;amp;nbsp;This is useful for those callbacks where many different return values are possible and it is easier to calculate them than list them in ranges. &amp;amp;nbsp;The default value must still be specified, and will be used in case the variable(s) used are not available.&lt;br /&gt;
&lt;br /&gt;
=== sets and ranges ===&lt;br /&gt;
&lt;br /&gt;
For each of the ranges to check, you give the set-id as a &#039;&#039;&#039;WORD&#039;&#039;&#039; value (i.e. with a 00 following, e.g. set-id 5 becomes 05 00, or - in case of a callback result - by setting the high bit, e.g. 05 80), followed by the low and high limits of this range. &amp;amp;nbsp;The first range that matches will be used.&lt;br /&gt;
&lt;br /&gt;
The various \b, \w, and \d escape sequences can be useful for &amp;lt;min-range&amp;gt; and &amp;lt;max-range&amp;gt;. See [[GRFActionsDetailed#Byte order|the discussion of escape sequences]] for further information.&lt;br /&gt;
&lt;br /&gt;
=== default ===&lt;br /&gt;
&lt;br /&gt;
The set-id to use if none of the ranges matches.&lt;br /&gt;
&lt;br /&gt;
=Example=&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 -1 * 15       02 05 03 81        // Action2, Feature 05 (canals), action2ID 03, 1-byte variable&lt;br /&gt;
                   81 00 04       // variable 81 (terrain type), shift 00, mask 0x04 (=bit for &amp;quot;on or above snowline&amp;quot;)&lt;br /&gt;
                   01             // check one range&lt;br /&gt;
                   02 00    04 04 // snowy tile: link to action2ID 02&lt;br /&gt;
                   01 00          // default:    link to action2ID 01&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gesia</name></author>
	</entry>
</feed>