<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.tt-wiki.net/index.php?action=history&amp;feed=atom&amp;title=Callbacks_Tutorial</id>
	<title>Callbacks Tutorial - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.tt-wiki.net/index.php?action=history&amp;feed=atom&amp;title=Callbacks_Tutorial"/>
	<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;action=history"/>
	<updated>2026-05-02T05:10:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=8027&amp;oldid=prev</id>
		<title>Orudge: moved CallbacksTut to Callbacks Tutorial:&amp;#32;Add spaces</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=8027&amp;oldid=prev"/>
		<updated>2012-03-01T12:00:09Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/wiki/CallbacksTut&quot; class=&quot;mw-redirect&quot; title=&quot;CallbacksTut&quot;&gt;CallbacksTut&lt;/a&gt; to &lt;a href=&quot;/wiki/Callbacks_Tutorial&quot; title=&quot;Callbacks Tutorial&quot;&gt;Callbacks Tutorial&lt;/a&gt;: Add spaces&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:00, 1 March 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en-GB&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Orudge</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=7775&amp;oldid=prev</id>
		<title>FooBar: add nav template</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=7775&amp;oldid=prev"/>
		<updated>2011-08-28T21:02:14Z</updated>

		<summary type="html">&lt;p&gt;add nav template&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-GB&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 21:02, 28 August 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&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 colspan=&quot;2&quot; class=&quot;diff-empty 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;{{NFOTutorial}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty 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;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;=Callbacks in Graphics Files=&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;=Callbacks in Graphics Files=&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;/table&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=7225&amp;oldid=prev</id>
		<title>Orudge: Reformat and update</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=7225&amp;oldid=prev"/>
		<updated>2011-07-30T17:15:49Z</updated>

		<summary type="html">&lt;p&gt;Reformat and update&lt;/p&gt;
&lt;a href=&quot;https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;amp;diff=7225&amp;amp;oldid=634&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Orudge</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=634&amp;oldid=prev</id>
		<title>Orudge: 12 revisions</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=634&amp;oldid=prev"/>
		<updated>2011-06-12T19:03:28Z</updated>

		<summary type="html">&lt;p&gt;12 revisions&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Tutorial on using callbacks&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=Callbacks in Graphics Files=&lt;br /&gt;
&lt;br /&gt;
Since TTDPatch 2.0.1 alpha 11, it is possible to use callbacks, in which the graphics files can influence how TTDPatch features work. This is a lot more sophisticated than simply using action 0 to choose various settings, in that callbacks can use the full capabilities of variational and random action 2 entries.&lt;br /&gt;
&lt;br /&gt;
-=How it works=-&lt;br /&gt;
&lt;br /&gt;
When the patch wants to use the value of certain properties, it can ask the graphics file what value to use, instead of simply looking it up in the table set by action 0. It does this if the corresponding callback bit has been set in the vehicle&amp;#039;s action 0 properties. Then, the following happens:&lt;br /&gt;
* The patch sets the current callback ID, variable 0C, according to what callback it is&lt;br /&gt;
* Then, the patch starts at the vehicle&amp;#039;s action 3 entry and finds the initial action 2 number to use&lt;br /&gt;
* The patch then follows the chain of variational/random action 2 entries&lt;br /&gt;
* The set-id of the final action 2 is used as result for the callback&lt;br /&gt;
&lt;br /&gt;
Because callbacks are different from regular vehicle graphics, the last action 2 in the chain must have a set-id with bit 15 set (e.g. XX 80 to return XX), which is invalid for regular graphics. &amp;amp;nbsp;Therefore, at least one action 2 in the chain must check the variable 0C, to decide whether this is a callback or the determination of graphics.&lt;br /&gt;
&lt;br /&gt;
-=How to define callbacks=-&lt;br /&gt;
&lt;br /&gt;
There are several things you have to do to get callbacks to work.&lt;br /&gt;
# If necessary, enable the callback. For vehicles, set the callback bit in the [[Action0|action 0]] property for the vehicle which should use callbacks (props 1E, 17, 12 or 14 depending on vehicle type)&lt;br /&gt;
# Set a default for the value that the callback modifies, e.g. set prop 07 when using the load amount callback&lt;br /&gt;
# Define an [[Action3|action 3]] for the vehicle if it doesn&amp;#039;t have one already&lt;br /&gt;
# Add a [[VariationalAction2|variational action 2]] that checks the callback variable 0C for the value of the callback. See the description of a variational action 2 to find what values those are.&lt;br /&gt;
# Variable 0C should be accessed as a word. Even when the callbacks IDs you want to test are below 0xFF.&lt;br /&gt;
# This variational action 2 has to return a callback result (set-id with bit 15 set) when in a callback, or a regular set-id when not in a callback&lt;br /&gt;
# Make sure that the &amp;amp;quot;default&amp;amp;quot; of the var. 0C check (corresponding to unknown callbacks) points to a regular action 2 instead of one that returns callback results, ideally using the same action 2 as in the non-callback case. This way, unknown callbacks will fail instead of returning valid, but wrong, results.&lt;br /&gt;
&lt;br /&gt;
As explained above, a callback result is something like -+06 80+- (with 06 being used as value of the callback), instead of a regular set-id that would be for example -+04 00+-.&lt;br /&gt;
&lt;br /&gt;
-=Examples=-&lt;br /&gt;
&lt;br /&gt;
Be aware that following examples don&amp;#039;t result into 100% complete newgrfs, but instead concentrate on the most important code features. E.g., in the given [[Action0Trains|action0s]] you&amp;#039;d have to add even more properties to get a well-working newgrf, or, in case an example describes only one vehicle in detail, references to other vehicles, e.g. a locomotive, are given in a symbolic form (&amp;amp;quot;xx&amp;amp;quot;, &amp;amp;quot;nn&amp;amp;quot;) rather than implementing it in detail and giving correct veh-IDs or c-IDs.&lt;br /&gt;
&lt;br /&gt;
-=Example1: using Callback 33 (new sounds)=-&lt;br /&gt;
&lt;br /&gt;
The first example is a simple application. It will set new sounds for a locomotive by using [[Callbacks#Sound_effect_callback_33_|callback 33]]. The new sounds will be supplied by two .wav files using [[Action11|action 11]]. Newly defined sounds will start from slot 73 (49h), numbers 0 - 48h being original TTD sounds. The type of event (under which circumstances a particular sound should be played) is read from variable 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;0F 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// set engine (00) to use new sprites, enable for callback 33&lt;br /&gt;
&lt;br /&gt;
2 * 9 &amp;amp;nbsp; &amp;amp;nbsp;00 00 02 01 00&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 80 &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 33&lt;br /&gt;
&lt;br /&gt;
// define sound files, first available slot being 49h&lt;br /&gt;
&lt;br /&gt;
3 * 3 &amp;amp;nbsp; &amp;amp;nbsp;11 02 00&lt;br /&gt;
&lt;br /&gt;
4 ** C:\ttdlx\newgrf\sprites\start.wav &amp;amp;nbsp; &amp;amp;nbsp;// 49: whistle (departure)&lt;br /&gt;
&lt;br /&gt;
5 ** C:\ttdlx\newgrf\sprites\tunnel.wav &amp;amp;nbsp; &amp;amp;nbsp;// 4A: whistle (in tunnel)&lt;br /&gt;
&lt;br /&gt;
// engine sprites go here&lt;br /&gt;
&lt;br /&gt;
6 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 01 04&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 4 sprites for engine&lt;br /&gt;
&lt;br /&gt;
// c-ID 0 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
11 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine&lt;br /&gt;
&lt;br /&gt;
// sound events are read from var10:&lt;br /&gt;
&lt;br /&gt;
12 * 18 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 81 10 00 FF 02&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;49 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// whistle: departure&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;4A 80 02 02 &amp;amp;nbsp; &amp;amp;nbsp;// whistle: in tunnel&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// else CB fail&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
13 * 17 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 33 00 33 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 33, set sound&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
14 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 00 00 02 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-=Example2: using Callbacks 12, 15, and 19=-&lt;br /&gt;
&lt;br /&gt;
Suppose you want to build passenger coaches with both first and second class, having different livery and capacity, loading amount, and additional text suffixes. For this to work we&amp;#039;ll need callbacks [[Callbacks#Load_amount_callback_12_|12 (load amount]]), [[Callbacks#Refitted_capacity_callback_15_|15 (refitted capacity]]) and [[Callbacks#Cargo_Subtype_Display_19_|19 (cargo subtype display]]):&lt;br /&gt;
&lt;br /&gt;
In addition, we&amp;#039;ll use the feature [[VarAction2Vehicles|&amp;amp;quot;refit to same cargo type&amp;amp;quot;]] to be able to change livery, loading amount and capacity deliberately, even if coaches carry only one type of cargo, namely &amp;amp;quot;passengers&amp;amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the .nfo, the actual &amp;amp;quot;refitting&amp;amp;quot; is done by referencing variable F2, which holds how many times a vehicle was refitted to the same cargo type. In game, there will be two entries generated in the refit menu containing these text suffixes generated by an [[Action4|action 4]]. Namely &amp;amp;quot;passengers (1st class)&amp;amp;quot; and &amp;amp;quot;passengers (2nd class)&amp;amp;quot; from which to choose the desired type of coach. Likewise, load amount and capacity are linked to variable F2 as well and will be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;15 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// define additional text suffixes&lt;br /&gt;
&lt;br /&gt;
2 * 0 &amp;amp;nbsp; &amp;amp;nbsp;04 00 1F 02 00 D0&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (1st class)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D000 = &amp;amp;quot;1st class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;quot; (2nd class)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D001 = &amp;amp;quot;2nd class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
// set coach (1B) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callbacks 12, 15 and 19&lt;br /&gt;
&lt;br /&gt;
3 * 9 &amp;amp;nbsp; &amp;amp;nbsp;00 00 02 01 1B&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 2C &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 12, 15 and 19&lt;br /&gt;
&lt;br /&gt;
// coach sprites go here&lt;br /&gt;
&lt;br /&gt;
4 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 02 04&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 4 sprites for 1st class coach&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 4 sprites for 2nd class coach&lt;br /&gt;
&lt;br /&gt;
// c-IDs 0..1 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
13 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class&lt;br /&gt;
&lt;br /&gt;
14 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class&lt;br /&gt;
&lt;br /&gt;
// next 4 pseudo sprites are checking var F2,&lt;br /&gt;
&lt;br /&gt;
// thus constituting the two refitting possibilities:&lt;br /&gt;
&lt;br /&gt;
// [1st class, 48 passengers, load amount = 6] &amp;amp;nbsp;and&lt;br /&gt;
&lt;br /&gt;
// [2nd class, 56 passengers, load amount = 8]&lt;br /&gt;
&lt;br /&gt;
// set load amount&lt;br /&gt;
&lt;br /&gt;
15 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 81 F2 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;06 80 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class = 6/tick&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;08 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class = 8/tick&lt;br /&gt;
&lt;br /&gt;
// set refitted capacity&lt;br /&gt;
&lt;br /&gt;
16 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 03 81 F2 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;30 80 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class = 48 pass&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;38 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class = 56 pass&lt;br /&gt;
&lt;br /&gt;
// set text suffixes&lt;br /&gt;
&lt;br /&gt;
17 * 18 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 81 F2 00 FF 02&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 80 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// &amp;amp;quot;1st class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// &amp;amp;quot;2nd class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FF 80&lt;br /&gt;
&lt;br /&gt;
// set livery&lt;br /&gt;
&lt;br /&gt;
18 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 05 81 F2 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class&lt;br /&gt;
&lt;br /&gt;
// switch between callbacks and graphics branch&lt;br /&gt;
&lt;br /&gt;
19 * 29 &amp;amp;nbsp; &amp;amp;nbsp;02 00 06 85 0C 00 FF FF 03&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 12 00 12 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB12, set load amount&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 15 00 15 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB15, set refit capacity&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;04 00 19 00 19 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB19, set text suffix&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;05 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
20 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 1B 00 06 00 &amp;amp;nbsp; &amp;amp;nbsp;// coach&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-=Example3: &amp;amp;nbsp;using callbacks 11 (wagon length) and 16 (articulated engine)=-&lt;br /&gt;
&lt;br /&gt;
This example will demonstrate how to use [[Callbacks#Articulated_engine_callback_16_|callback 16]] for designing &amp;amp;quot;articulated vehicles&amp;amp;quot;, e.g. locomotives with tenders. We&amp;#039;ll set up two locomotives using two different tenders: &amp;amp;lt;engine1&amp;amp;gt; will use a standard short &amp;amp;lt;tender1&amp;amp;gt; and &amp;amp;lt;engine2&amp;amp;gt; will use the even shorter &amp;amp;lt;tender2&amp;amp;gt; by applying &amp;amp;nbsp;[[Callbacks#Wagon_length_callback_11_|callback 11]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;34 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// set the generic tender (2D) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callback 11&lt;br /&gt;
&lt;br /&gt;
2 * 13 &amp;amp;nbsp; &amp;amp;nbsp;00 00 04 01 2D&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;06 00 &amp;amp;nbsp; &amp;amp;nbsp;// don&amp;#039;t show up in menu&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 02 &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 11&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;21 02 &amp;amp;nbsp; &amp;amp;nbsp;// make shorter by 25%&lt;br /&gt;
&lt;br /&gt;
// tender sprites go here&lt;br /&gt;
&lt;br /&gt;
3 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 02 08&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for tender1&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for tender2&lt;br /&gt;
&lt;br /&gt;
// Cargo-ids 0..1 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
20 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 F0 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// tender1 (F0)&lt;br /&gt;
&lt;br /&gt;
21 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// tender2&lt;br /&gt;
&lt;br /&gt;
// tender2 (F1) is shorter&lt;br /&gt;
&lt;br /&gt;
22 * 18 &amp;amp;nbsp; &amp;amp;nbsp;02 00 F1 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 80 11 00 11 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB11: make shorter by 37.5%&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
23 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 2D 00 F0 00 &amp;amp;nbsp; &amp;amp;nbsp;// standard tender&lt;br /&gt;
&lt;br /&gt;
// set two engines (00 and 01) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callback 16&lt;br /&gt;
&lt;br /&gt;
24 * 11 &amp;amp;nbsp; &amp;amp;nbsp;00 00 02 02 00&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 10 10 &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 16&lt;br /&gt;
&lt;br /&gt;
// engine sprites go here&lt;br /&gt;
&lt;br /&gt;
25 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 02 08&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for engine1&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for engine2&lt;br /&gt;
&lt;br /&gt;
// Cargo-ids 0..1 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
42 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine1&lt;br /&gt;
&lt;br /&gt;
43 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine2&lt;br /&gt;
&lt;br /&gt;
// &amp;amp;lt;engine1&amp;amp;gt; uses standard &amp;amp;lt;tender1&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
// engine is articulated, so show either engine (00) or tender (F0)&lt;br /&gt;
&lt;br /&gt;
44 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 81 41 00 01 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine1&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;F0 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// tender1&lt;br /&gt;
&lt;br /&gt;
// set articulated CB&lt;br /&gt;
&lt;br /&gt;
45 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 03 81 10 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;2D 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// add tender (2D)&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FF 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// end of articulated vehicle&lt;br /&gt;
&lt;br /&gt;
// Switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
46 * 17 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB16, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
47 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 00 00 04 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine1 with tender1&lt;br /&gt;
&lt;br /&gt;
// &amp;amp;lt;engine2&amp;amp;gt; uses shorter &amp;amp;lt;tender2&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
// engine is articulated, so show either engine (01) or tender (F1)&lt;br /&gt;
&lt;br /&gt;
48 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 81 41 00 01 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine2&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;F1 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// tender2&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
49 * 17 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 16, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// (same as for &amp;amp;lt;engine1&amp;amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
50 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 01 00 04 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine2&lt;br /&gt;
&lt;br /&gt;
51 * 7 &amp;amp;nbsp;03 00 81 2D 00 F1 00 &amp;amp;nbsp; &amp;amp;nbsp;// override with tender2&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-=Example4: using Callbacks 10, 16, 1D and 23=-&lt;br /&gt;
&lt;br /&gt;
This example explains how to use [[Callbacks#Articulated_engine_callback_10_|callbacks 10 (power]]), [[Callbacks#Articulated_engine_callback_16_|16 (articulated]]),&lt;br /&gt;
&lt;br /&gt;
[[Callbacks#Articulated_engine_callback_1D_|1D (engine attach]]), and [[Callbacks#Articulated_engine_callback_23_|23 (additional text in menu]]) to construct a four-part EMU.&lt;br /&gt;
&lt;br /&gt;
The EMU is composed from the same building block, an electric rail car (veh-ID = 62). In addition, it should be allowed to link three of these four-part EMUs, i.e. a full consist may contain 12 rail cars in total.&lt;br /&gt;
&lt;br /&gt;
For sake of realism, no &amp;amp;quot;foreign&amp;amp;quot; vehicles should be allowed to be attached to the EMU. This is achieved by checking the veh-ID from [[VarAction2Vehicles|variable C6]]. Appropriate error messages will be generated if there&amp;#039;s something wrong, either with number or with type of added vehicles.&lt;br /&gt;
&lt;br /&gt;
Please notice that CBs 1D and 23 do not need a bit set in action0&amp;#039;s property 1E.&lt;br /&gt;
&lt;br /&gt;
Furthermore, it is shown how to make an explicit menu entry for such an EMU. For this to work, we need an extra sprite depicting not the single rail car but the complete four-part EMU. Because this sprite will be used only inside the buying menu, the corresponding sprite block needs only this single sprite for the horizontal direction. All other directions are not needed and hence we don&amp;#039;t have to include sprites for them.&lt;br /&gt;
&lt;br /&gt;
Also, the variable action2 chain for the menu entry need references for callbacks 16 and 23. The latter is used to place the text of additional information into the menu entry, and CB 16 is needed to get the capacity of the four-part EMU to show up correctly in the buying menu.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;39 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// CB 1D error messages&lt;br /&gt;
&lt;br /&gt;
2 * 0 &amp;amp;nbsp; &amp;amp;nbsp;04 00 81 02 20 D0&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (wrong number of cars)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D020&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (wrong type of car)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D021&lt;br /&gt;
&lt;br /&gt;
// CB 23 additional text for menu&lt;br /&gt;
&lt;br /&gt;
3 * 0 &amp;amp;nbsp; &amp;amp;nbsp;04 00 81 01 22 D0&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;0d 91 &amp;amp;quot;4-part EMU for commuter service.&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (Links max 12 parts)&amp;amp;quot; 00&lt;br /&gt;
&lt;br /&gt;
// set rail car (62) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callbacks 10 and 16&lt;br /&gt;
&lt;br /&gt;
4 * 11 &amp;amp;nbsp; &amp;amp;nbsp;00 00 03 01 62&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;19 30 &amp;amp;nbsp; &amp;amp;nbsp;// electric traction&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 11 &amp;amp;nbsp; &amp;amp;nbsp;// enable CBs 10 and 16&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
// the &amp;amp;quot;train&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
// all rail car sprites go here&lt;br /&gt;
&lt;br /&gt;
5 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 04 08&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 1st car&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 2nd car&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 3rd car&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 4th car&lt;br /&gt;
&lt;br /&gt;
// c-IDs 0..3 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
38 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st car&lt;br /&gt;
&lt;br /&gt;
39 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// 2nd car&lt;br /&gt;
&lt;br /&gt;
40 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 01 01 02 00 02 00 &amp;amp;nbsp; &amp;amp;nbsp;// 3rd car&lt;br /&gt;
&lt;br /&gt;
41 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 03 01 01 03 00 03 00 &amp;amp;nbsp; &amp;amp;nbsp;// 4th car&lt;br /&gt;
&lt;br /&gt;
// determine which car we are at. AND-ing the number of vehicles&lt;br /&gt;
&lt;br /&gt;
// in consist is more efficient as a &amp;amp;quot;modulo-4&amp;amp;quot; operation would be.&lt;br /&gt;
&lt;br /&gt;
42 * 22 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 81 40 00 03 03&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 03 03 &amp;amp;nbsp; &amp;amp;nbsp;// 4th car&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 02 &amp;amp;nbsp; &amp;amp;nbsp;// 3rd car&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// 2nd car&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 1st car&lt;br /&gt;
&lt;br /&gt;
// set CB 16 (articulated vehicle)&lt;br /&gt;
&lt;br /&gt;
43 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 05 81 10 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;62 80 01 03 &amp;amp;nbsp; &amp;amp;nbsp;// 3 additional parts of veh-ID 62&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FF 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// end articulated vehicle&lt;br /&gt;
&lt;br /&gt;
// set CB 1D (engine attach)&lt;br /&gt;
&lt;br /&gt;
// allow only 3 * EMU (= 12 cars) in total&lt;br /&gt;
&lt;br /&gt;
44 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 06 82 40 10 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FE 80 00 09 &amp;amp;nbsp; &amp;amp;nbsp;// allow adding of max 8 cars&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;20 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// error: &amp;amp;quot;wrong number of cars&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
// allow only EMU to attach itself, nothing else&lt;br /&gt;
&lt;br /&gt;
45 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 07 81 C6 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;06 00 62 62 &amp;amp;nbsp; &amp;amp;nbsp;// allow&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;21 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// error: &amp;amp;quot;wrong type of car&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
// only car1 and, if exist, 5 and 9 should be sparking&lt;br /&gt;
&lt;br /&gt;
// we&amp;#039;re using a modulo-4 operation -&amp;amp;gt; 80-FF-00-04&lt;br /&gt;
&lt;br /&gt;
46 * 16 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 08 81 40 80 FF 00 04 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;33 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// sparks&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;40 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// no sparks&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
47 * 29 &amp;amp;nbsp; &amp;amp;nbsp;02 00 09 85 0C 00 FF FF 03&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;05 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB16, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;07 00 1D 00 1D 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 1D, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;08 00 10 00 10 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 10, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;04 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
// menu entry&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
48 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 01 04&lt;br /&gt;
&lt;br /&gt;
49 * 1 &amp;amp;nbsp; &amp;amp;nbsp;00&lt;br /&gt;
&lt;br /&gt;
50 * 1 &amp;amp;nbsp; &amp;amp;nbsp;00&lt;br /&gt;
&lt;br /&gt;
51 C:\ttdlx\newgrf\sprites\emu.pcx 226 120 01 15 91 -27 -11&lt;br /&gt;
&lt;br /&gt;
52 * 1 &amp;amp;nbsp; &amp;amp;nbsp;00&lt;br /&gt;
&lt;br /&gt;
53 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
54 * 23 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 85 0C 00 FF FF 02&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;05 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// CB 16 (for capacity calculation)&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;22 80 23 00 23 00 &amp;amp;nbsp; &amp;amp;nbsp;// CB 23, show additional text&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
55 * 10 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 62 01 FF 01 00 09 00&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Orudge</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=623&amp;oldid=prev</id>
		<title>Frosch at 15:04, 21 June 2009</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=623&amp;oldid=prev"/>
		<updated>2009-06-21T15:04:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Tutorial on using callbacks&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=Callbacks in Graphics Files=&lt;br /&gt;
&lt;br /&gt;
Since TTDPatch 2.0.1 alpha 11, it is possible to use callbacks, in which the graphics files can influence how TTDPatch features work. This is a lot more sophisticated than simply using action 0 to choose various settings, in that callbacks can use the full capabilities of variational and random action 2 entries.&lt;br /&gt;
&lt;br /&gt;
-=How it works=-&lt;br /&gt;
&lt;br /&gt;
When the patch wants to use the value of certain properties, it can ask the graphics file what value to use, instead of simply looking it up in the table set by action 0. It does this if the corresponding callback bit has been set in the vehicle&amp;#039;s action 0 properties. Then, the following happens:&lt;br /&gt;
* The patch sets the current callback ID, variable 0C, according to what callback it is&lt;br /&gt;
* Then, the patch starts at the vehicle&amp;#039;s action 3 entry and finds the initial action 2 number to use&lt;br /&gt;
* The patch then follows the chain of variational/random action 2 entries&lt;br /&gt;
* The set-id of the final action 2 is used as result for the callback&lt;br /&gt;
&lt;br /&gt;
Because callbacks are different from regular vehicle graphics, the last action 2 in the chain must have a set-id with bit 15 set (e.g. XX 80 to return XX), which is invalid for regular graphics. &amp;amp;nbsp;Therefore, at least one action 2 in the chain must check the variable 0C, to decide whether this is a callback or the determination of graphics.&lt;br /&gt;
&lt;br /&gt;
-=How to define callbacks=-&lt;br /&gt;
&lt;br /&gt;
There are several things you have to do to get callbacks to work.&lt;br /&gt;
# If necessary, enable the callback. For vehicles, set the callback bit in the [[Action0|action 0]] property for the vehicle which should use callbacks (props 1E, 17, 12 or 14 depending on vehicle type)&lt;br /&gt;
# Set a default for the value that the callback modifies, e.g. set prop 07 when using the load amount callback&lt;br /&gt;
# Define an [[Action3|action 3]] for the vehicle if it doesn&amp;#039;t have one already&lt;br /&gt;
# Add a [[VariationalAction2|variational action 2]] that checks the callback variable 0C for the value of the callback. See the description of a variational action 2 to find what values those are.&lt;br /&gt;
# Variable 0C should be accessed as a word. Even when the callbacks IDs you want to test are below 0xFF.&lt;br /&gt;
# This variational action 2 has to return a callback result (set-id with bit 15 set) when in a callback, or a regular set-id when not in a callback&lt;br /&gt;
# Make sure that the &amp;amp;quot;default&amp;amp;quot; of the var. 0C check (corresponding to unknown callbacks) points to a regular action 2 instead of one that returns callback results, ideally using the same action 2 as in the non-callback case. This way, unknown callbacks will fail instead of returning valid, but wrong, results.&lt;br /&gt;
&lt;br /&gt;
As explained above, a callback result is something like -+06 80+- (with 06 being used as value of the callback), instead of a regular set-id that would be for example -+04 00+-.&lt;br /&gt;
&lt;br /&gt;
-=Examples=-&lt;br /&gt;
&lt;br /&gt;
Be aware that following examples don&amp;#039;t result into 100% complete newgrfs, but instead concentrate on the most important code features. E.g., in the given [[Action0Trains|action0s]] you&amp;#039;d have to add even more properties to get a well-working newgrf, or, in case an example describes only one vehicle in detail, references to other vehicles, e.g. a locomotive, are given in a symbolic form (&amp;amp;quot;xx&amp;amp;quot;, &amp;amp;quot;nn&amp;amp;quot;) rather than implementing it in detail and giving correct veh-IDs or c-IDs.&lt;br /&gt;
&lt;br /&gt;
-=Example1: using Callback 33 (new sounds)=-&lt;br /&gt;
&lt;br /&gt;
The first example is a simple application. It will set new sounds for a locomotive by using [[Callbacks#Sound_effect_callback_33_|callback 33]]. The new sounds will be supplied by two .wav files using [[Action11|action 11]]. Newly defined sounds will start from slot 73 (49h), numbers 0 - 48h being original TTD sounds. The type of event (under which circumstances a particular sound should be played) is read from variable 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;0F 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// set engine (00) to use new sprites, enable for callback 33&lt;br /&gt;
&lt;br /&gt;
2 * 9 &amp;amp;nbsp; &amp;amp;nbsp;00 00 02 01 00&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 80 &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 33&lt;br /&gt;
&lt;br /&gt;
// define sound files, first available slot being 49h&lt;br /&gt;
&lt;br /&gt;
3 * 3 &amp;amp;nbsp; &amp;amp;nbsp;11 02 00&lt;br /&gt;
&lt;br /&gt;
4 ** C:\ttdlx\newgrf\sprites\start.wav &amp;amp;nbsp; &amp;amp;nbsp;// 49: whistle (departure)&lt;br /&gt;
&lt;br /&gt;
5 ** C:\ttdlx\newgrf\sprites\tunnel.wav &amp;amp;nbsp; &amp;amp;nbsp;// 4A: whistle (in tunnel)&lt;br /&gt;
&lt;br /&gt;
// engine sprites go here&lt;br /&gt;
&lt;br /&gt;
6 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 01 04&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 4 sprites for engine&lt;br /&gt;
&lt;br /&gt;
// c-ID 0 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
11 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine&lt;br /&gt;
&lt;br /&gt;
// sound events are read from var10:&lt;br /&gt;
&lt;br /&gt;
12 * 18 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 81 10 00 FF 02&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;49 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// whistle: departure&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;4A 80 02 02 &amp;amp;nbsp; &amp;amp;nbsp;// whistle: in tunnel&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// else CB fail&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
13 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 33 00 33 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 33, set sound&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
14 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 00 00 02 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-=Example2: using Callbacks 12, 15, and 19=-&lt;br /&gt;
&lt;br /&gt;
Suppose you want to build passenger coaches with both first and second class, having different livery and capacity, loading amount, and additional text suffixes. For this to work we&amp;#039;ll need callbacks [[Callbacks#Load_amount_callback_12_|12 (load amount]]), [[Callbacks#Refitted_capacity_callback_15_|15 (refitted capacity]]) and [[Callbacks#Cargo_Subtype_Display_19_|19 (cargo subtype display]]):&lt;br /&gt;
&lt;br /&gt;
In addition, we&amp;#039;ll use the feature [[VarAction2Vehicles|&amp;amp;quot;refit to same cargo type&amp;amp;quot;]] to be able to change livery, loading amount and capacity deliberately, even if coaches carry only one type of cargo, namely &amp;amp;quot;passengers&amp;amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the .nfo, the actual &amp;amp;quot;refitting&amp;amp;quot; is done by referencing variable F2, which holds how many times a vehicle was refitted to the same cargo type. In game, there will be two entries generated in the refit menu containing these text suffixes generated by an [[Action4|action 4]]. Namely &amp;amp;quot;passengers (1st class)&amp;amp;quot; and &amp;amp;quot;passengers (2nd class)&amp;amp;quot; from which to choose the desired type of coach. Likewise, load amount and capacity are linked to variable F2 as well and will be changed accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;15 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// define additional text suffixes&lt;br /&gt;
&lt;br /&gt;
2 * 0 &amp;amp;nbsp; &amp;amp;nbsp;04 00 1F 02 00 D0&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (1st class)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D000 = &amp;amp;quot;1st class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;quot; (2nd class)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D001 = &amp;amp;quot;2nd class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
// set coach (1B) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callbacks 12, 15 and 19&lt;br /&gt;
&lt;br /&gt;
3 * 9 &amp;amp;nbsp; &amp;amp;nbsp;00 00 02 01 1B&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 2C &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 12, 15 and 19&lt;br /&gt;
&lt;br /&gt;
// coach sprites go here&lt;br /&gt;
&lt;br /&gt;
4 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 02 04&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 4 sprites for 1st class coach&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 4 sprites for 2nd class coach&lt;br /&gt;
&lt;br /&gt;
// c-IDs 0..1 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
13 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class&lt;br /&gt;
&lt;br /&gt;
14 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class&lt;br /&gt;
&lt;br /&gt;
// next 4 pseudo sprites are checking var F2,&lt;br /&gt;
&lt;br /&gt;
// thus constituting the two refitting possibilities:&lt;br /&gt;
&lt;br /&gt;
// [1st class, 48 passengers, load amount = 6] &amp;amp;nbsp;and&lt;br /&gt;
&lt;br /&gt;
// [2nd class, 56 passengers, load amount = 8]&lt;br /&gt;
&lt;br /&gt;
// set load amount&lt;br /&gt;
&lt;br /&gt;
15 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 81 F2 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;06 80 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class = 6/tick&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;08 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class = 8/tick&lt;br /&gt;
&lt;br /&gt;
// set refitted capacity&lt;br /&gt;
&lt;br /&gt;
16 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 03 81 F2 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;30 80 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class = 48 pass&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;38 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class = 56 pass&lt;br /&gt;
&lt;br /&gt;
// set text suffixes&lt;br /&gt;
&lt;br /&gt;
17 * 18 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 81 F2 00 FF 02&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 80 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// &amp;amp;quot;1st class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// &amp;amp;quot;2nd class&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FF 80&lt;br /&gt;
&lt;br /&gt;
// set livery&lt;br /&gt;
&lt;br /&gt;
18 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 05 81 F2 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st class&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 2nd class&lt;br /&gt;
&lt;br /&gt;
// switch between callbacks and graphics branch&lt;br /&gt;
&lt;br /&gt;
19 * 22 &amp;amp;nbsp; &amp;amp;nbsp;02 00 06 85 0C 00 FF FF 03&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 12 00 12 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB12, set load amount&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 15 00 15 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB15, set refit capacity&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;04 00 19 00 19 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB19, set text suffix&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;05 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
20 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 1B 00 06 00 &amp;amp;nbsp; &amp;amp;nbsp;// coach&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-=Example3: &amp;amp;nbsp;using callbacks 11 (wagon length) and 16 (articulated engine)=-&lt;br /&gt;
&lt;br /&gt;
This example will demonstrate how to use [[Callbacks#Articulated_engine_callback_16_|callback 16]] for designing &amp;amp;quot;articulated vehicles&amp;amp;quot;, e.g. locomotives with tenders. We&amp;#039;ll set up two locomotives using two different tenders: &amp;amp;lt;engine1&amp;amp;gt; will use a standard short &amp;amp;lt;tender1&amp;amp;gt; and &amp;amp;lt;engine2&amp;amp;gt; will use the even shorter &amp;amp;lt;tender2&amp;amp;gt; by applying &amp;amp;nbsp;[[Callbacks#Wagon_length_callback_11_|callback 11]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;34 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// set the generic tender (2D) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callback 11&lt;br /&gt;
&lt;br /&gt;
2 * 13 &amp;amp;nbsp; &amp;amp;nbsp;00 00 04 01 2D&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;06 00 &amp;amp;nbsp; &amp;amp;nbsp;// don&amp;#039;t show up in menu&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 02 &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 11&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;21 02 &amp;amp;nbsp; &amp;amp;nbsp;// make shorter by 25%&lt;br /&gt;
&lt;br /&gt;
// tender sprites go here&lt;br /&gt;
&lt;br /&gt;
3 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 02 08&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for tender1&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for tender2&lt;br /&gt;
&lt;br /&gt;
// Cargo-ids 0..1 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
20 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 F0 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// tender1 (F0)&lt;br /&gt;
&lt;br /&gt;
21 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// tender2&lt;br /&gt;
&lt;br /&gt;
// tender2 (F1) is shorter&lt;br /&gt;
&lt;br /&gt;
22 * 18 &amp;amp;nbsp; &amp;amp;nbsp;02 00 F1 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 80 11 00 11 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB11: make shorter by 37.5%&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
23 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 2D 00 F0 00 &amp;amp;nbsp; &amp;amp;nbsp;// standard tender&lt;br /&gt;
&lt;br /&gt;
// set two engines (00 and 01) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callback 16&lt;br /&gt;
&lt;br /&gt;
24 * 11 &amp;amp;nbsp; &amp;amp;nbsp;00 00 02 02 00&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 10 10 &amp;amp;nbsp; &amp;amp;nbsp;// enable CB 16&lt;br /&gt;
&lt;br /&gt;
// engine sprites go here&lt;br /&gt;
&lt;br /&gt;
25 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 02 08&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for engine1&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// 8 sprites for engine2&lt;br /&gt;
&lt;br /&gt;
// Cargo-ids 0..1 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
42 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine1&lt;br /&gt;
&lt;br /&gt;
43 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine2&lt;br /&gt;
&lt;br /&gt;
// &amp;amp;lt;engine1&amp;amp;gt; uses standard &amp;amp;lt;tender1&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
// engine is articulated, so show either engine (00) or tender (F0)&lt;br /&gt;
&lt;br /&gt;
44 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 81 41 00 01 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine1&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;F0 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// tender1&lt;br /&gt;
&lt;br /&gt;
// set articulated CB&lt;br /&gt;
&lt;br /&gt;
45 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 03 81 10 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;2D 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// add tender (2D)&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FF 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// end of articulated vehicle&lt;br /&gt;
&lt;br /&gt;
// Switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
46 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB16, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
47 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 00 00 04 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine1 with tender1&lt;br /&gt;
&lt;br /&gt;
// &amp;amp;lt;engine2&amp;amp;gt; uses shorter &amp;amp;lt;tender2&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
// engine is articulated, so show either engine (01) or tender (F1)&lt;br /&gt;
&lt;br /&gt;
48 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 81 41 00 01 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine2&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;F1 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// tender2&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
49 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 85 0C 00 FF FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 16, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// (same as for &amp;amp;lt;engine1&amp;amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
50 * 7 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 01 00 04 00 &amp;amp;nbsp; &amp;amp;nbsp;// engine2&lt;br /&gt;
&lt;br /&gt;
51 * 7 &amp;amp;nbsp;03 00 81 2D 00 F1 00 &amp;amp;nbsp; &amp;amp;nbsp;// override with tender2&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-=Example4: using Callbacks 10, 16, 1D and 23=-&lt;br /&gt;
&lt;br /&gt;
This example explains how to use [[Callbacks#Articulated_engine_callback_10_|callbacks 10 (power]]), [[Callbacks#Articulated_engine_callback_16_|16 (articulated]]),&lt;br /&gt;
&lt;br /&gt;
[[Callbacks#Articulated_engine_callback_1D_|1D (engine attach]]), and [[Callbacks#Articulated_engine_callback_23_|23 (additional text in menu]]) to construct a four-part EMU.&lt;br /&gt;
&lt;br /&gt;
The EMU is composed from the same building block, an electric rail car (veh-ID = 62). In addition, it should be allowed to link three of these four-part EMUs, i.e. a full consist may contain 12 rail cars in total.&lt;br /&gt;
&lt;br /&gt;
For sake of realism, no &amp;amp;quot;foreign&amp;amp;quot; vehicles should be allowed to be attached to the EMU. This is achieved by checking the veh-ID from [[VarAction2Vehicles|variable C6]]. Appropriate error messages will be generated if there&amp;#039;s something wrong, either with number or with type of added vehicles.&lt;br /&gt;
&lt;br /&gt;
Please notice that CBs 1D and 23 do not need a bit set in action0&amp;#039;s property 1E.&lt;br /&gt;
&lt;br /&gt;
Furthermore, it is shown how to make an explicit menu entry for such an EMU. For this to work, we need an extra sprite depicting not the single rail car but the complete four-part EMU. Because this sprite will be used only inside the buying menu, the corresponding sprite block needs only this single sprite for the horizontal direction. All other directions are not needed and hence we don&amp;#039;t have to include sprites for them.&lt;br /&gt;
&lt;br /&gt;
Also, the variable action2 chain for the menu entry need references for callbacks 16 and 23. The latter is used to place the text of additional information into the menu entry, and CB 16 is needed to get the capacity of the four-part EMU to show up correctly in the buying menu.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~&lt;br /&gt;
&lt;br /&gt;
0 * 4 &amp;amp;nbsp; &amp;amp;nbsp;39 00 00 00&lt;br /&gt;
&lt;br /&gt;
// add an action 08&lt;br /&gt;
&lt;br /&gt;
1 * 8 &amp;amp;nbsp; &amp;amp;nbsp;08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// CB 1D error messages&lt;br /&gt;
&lt;br /&gt;
2 * 0 &amp;amp;nbsp; &amp;amp;nbsp;04 00 81 02 20 D0&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (wrong number of cars)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D020&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (wrong type of car)&amp;amp;quot; 00 &amp;amp;nbsp; &amp;amp;nbsp;// D021&lt;br /&gt;
&lt;br /&gt;
// CB 23 additional text for menu&lt;br /&gt;
&lt;br /&gt;
3 * 0 &amp;amp;nbsp; &amp;amp;nbsp;04 00 81 01 22 D0&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;0d 91 &amp;amp;quot;4-part EMU for commuter service.&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&amp;amp;quot; (Links max 12 parts)&amp;amp;quot; 00&lt;br /&gt;
&lt;br /&gt;
// set rail car (62) to use new sprites,&lt;br /&gt;
&lt;br /&gt;
// enable for callbacks 10 and 16&lt;br /&gt;
&lt;br /&gt;
4 * 11 &amp;amp;nbsp; &amp;amp;nbsp;00 00 03 01 62&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;12 FD &amp;amp;nbsp; &amp;amp;nbsp;// use new sprites&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;19 30 &amp;amp;nbsp; &amp;amp;nbsp;// electric traction&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;1E 11 &amp;amp;nbsp; &amp;amp;nbsp;// enable CBs 10 and 16&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
// the &amp;amp;quot;train&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
// all rail car sprites go here&lt;br /&gt;
&lt;br /&gt;
5 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 04 08&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 1st car&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 2nd car&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 3rd car&lt;br /&gt;
&lt;br /&gt;
[...] &amp;amp;nbsp; &amp;amp;nbsp;// sprites for 4th car&lt;br /&gt;
&lt;br /&gt;
// c-IDs 0..3 use above set of sprites&lt;br /&gt;
&lt;br /&gt;
38 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00 &amp;amp;nbsp; &amp;amp;nbsp;// 1st car&lt;br /&gt;
&lt;br /&gt;
39 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 01 01 01 00 01 00 &amp;amp;nbsp; &amp;amp;nbsp;// 2nd car&lt;br /&gt;
&lt;br /&gt;
40 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 01 01 02 00 02 00 &amp;amp;nbsp; &amp;amp;nbsp;// 3rd car&lt;br /&gt;
&lt;br /&gt;
41 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 03 01 01 03 00 03 00 &amp;amp;nbsp; &amp;amp;nbsp;// 4th car&lt;br /&gt;
&lt;br /&gt;
// determine which car we are at. AND-ing the number of vehicles&lt;br /&gt;
&lt;br /&gt;
// in consist is more efficient as a &amp;amp;quot;modulo-4&amp;amp;quot; operation would be.&lt;br /&gt;
&lt;br /&gt;
42 * 22 &amp;amp;nbsp; &amp;amp;nbsp;02 00 04 81 40 00 03 03&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;03 00 03 03 &amp;amp;nbsp; &amp;amp;nbsp;// 4th car&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 02 02 &amp;amp;nbsp; &amp;amp;nbsp;// 3rd car&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;01 00 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// 2nd car&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// 1st car&lt;br /&gt;
&lt;br /&gt;
// set CB 16 (articulated vehicle)&lt;br /&gt;
&lt;br /&gt;
43 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 05 81 10 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;62 80 01 03 &amp;amp;nbsp; &amp;amp;nbsp;// 3 additional parts of veh-ID 62&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FF 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// end articulated vehicle&lt;br /&gt;
&lt;br /&gt;
// set CB 1D (engine attach)&lt;br /&gt;
&lt;br /&gt;
// allow only 3 * EMU (= 12 cars) in total&lt;br /&gt;
&lt;br /&gt;
44 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 06 82 40 10 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;FE 80 00 09 &amp;amp;nbsp; &amp;amp;nbsp;// allow adding of max 8 cars&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;20 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// error: &amp;amp;quot;wrong number of cars&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
// allow only EMU to attach itself, nothing else&lt;br /&gt;
&lt;br /&gt;
45 * 14 &amp;amp;nbsp; &amp;amp;nbsp;02 00 07 81 C6 00 FF 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;06 00 62 62 &amp;amp;nbsp; &amp;amp;nbsp;// allow&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;21 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// error: &amp;amp;quot;wrong type of car&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
// only car1 and, if exist, 5 and 9 should be sparking&lt;br /&gt;
&lt;br /&gt;
// we&amp;#039;re using a modulo-4 operation -&amp;amp;gt; 80-FF-00-04&lt;br /&gt;
&lt;br /&gt;
46 * 16 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;02 00 08 81 40 80 FF 00 04 01&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;33 80 01 01 &amp;amp;nbsp; &amp;amp;nbsp;// sparks&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;40 80 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// no sparks&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
47 * 22 &amp;amp;nbsp; &amp;amp;nbsp;02 00 09 85 0C 00 FF FF 03&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;05 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB16, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;07 00 1D 00 1D 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 1D, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;08 00 10 00 10 00 &amp;amp;nbsp; &amp;amp;nbsp;// is CB 10, handle it&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;04 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
// menu entry&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
48 * 4 &amp;amp;nbsp; &amp;amp;nbsp;01 00 01 04&lt;br /&gt;
&lt;br /&gt;
49 * 1 &amp;amp;nbsp; &amp;amp;nbsp;00&lt;br /&gt;
&lt;br /&gt;
50 * 1 &amp;amp;nbsp; &amp;amp;nbsp;00&lt;br /&gt;
&lt;br /&gt;
51 C:\ttdlx\newgrf\sprites\emu.pcx 226 120 01 15 91 -27 -11&lt;br /&gt;
&lt;br /&gt;
52 * 1 &amp;amp;nbsp; &amp;amp;nbsp;00&lt;br /&gt;
&lt;br /&gt;
53 * 9 &amp;amp;nbsp; &amp;amp;nbsp;02 00 00 01 01 00 00 00 00&lt;br /&gt;
&lt;br /&gt;
// switch between callback and graphics branch&lt;br /&gt;
&lt;br /&gt;
54 * 18 &amp;amp;nbsp; &amp;amp;nbsp;02 00 01 85 0C 00 FF FF 02&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;05 00 16 00 16 00 &amp;amp;nbsp; &amp;amp;nbsp;// CB 16 (for capacity calculation)&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;22 80 23 00 23 00 &amp;amp;nbsp; &amp;amp;nbsp;// CB 23, show additional text&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;00 00 &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;// graphics&lt;br /&gt;
&lt;br /&gt;
55 * 10 &amp;amp;nbsp; &amp;amp;nbsp;03 00 01 62 01 FF 01 00 09 00&lt;br /&gt;
&lt;br /&gt;
~/pp~&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Frosch</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=630&amp;oldid=prev</id>
		<title>peter1138 at 10:31, 3 June 2008</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=630&amp;oldid=prev"/>
		<updated>2008-06-03T10:31:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Tutorial on using callbacks&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=Callbacks in Graphics Files=&lt;br /&gt;
&lt;br /&gt;
Since TTDPatch 2.0.1 alpha 11, it is possible to use callbacks, in which the graphics files can influence how TTDPatch features work. This is a lot more sophisticated than simply using action 0 to choose various settings, in that callbacks can use the full capabilities of variational and random action 2 entries.&lt;br /&gt;
&lt;br /&gt;
-=How it works=-&lt;br /&gt;
&lt;br /&gt;
When the patch wants to use the value of certain properties, it can ask the graphics file what value to use, instead of simply looking it up in the table set by action 0. It does this if the corresponding callback bit has been set in the vehicle&amp;#039;s action 0 properties. Then, the following happens:&lt;br /&gt;
* The patch sets the current callback ID, variable 0C, according to what callback it is&lt;br /&gt;
* Then, the patch starts at the vehicle&amp;#039;s action 3 entry and finds the initial action 2 number to use&lt;br /&gt;
* The patch then follows the chain of variational/random action 2 entries&lt;br /&gt;
* The set-id of the final action 2 is used as result for the callback&lt;br /&gt;
&lt;br /&gt;
Because callbacks are different from regular vehicle graphics, the last action 2 in the chain must have a set-id with bit 15 set (e.g. XX 80 to return XX), which is invalid for regular graphics. &amp;amp;nbsp;Therefore, at least one action 2 in the chain must check the variable 0C, to decide whether this is a callback or the determination of graphics.&lt;br /&gt;
&lt;br /&gt;
-=How to define callbacks=-&lt;br /&gt;
&lt;br /&gt;
There are several things you have to do to get callbacks to work.&lt;br /&gt;
# If necessary, enable the callback. For vehicles, set the callback bit in the [[Action0|action 0]] property for the vehicle which should use callbacks (props 1E, 17, 12 or 14 depending on vehicle type)&lt;br /&gt;
# Set a default for the value that the callback modifies, e.g. set prop 07 when using the load amount callback&lt;br /&gt;
# Define an [[Action3|action 3]] for the vehicle if it doesn&amp;#039;t have one already&lt;br /&gt;
# Add a [[VariationalAction2|variational action 2]] that checks the callback variable 0C for the value of the callback. See the description of a variational action 2 to find what values those are.&lt;br /&gt;
# This variational action 2 has to return a callback result (set-id with bit 15 set) when in a callback, or a regular set-id when not in a callback&lt;br /&gt;
# Make sure that the &amp;amp;quot;default&amp;amp;quot; of the var. 0C check (corresponding to unknown callbacks) points to a regular action 2 instead of one that returns callback results, ideally using the same action 2 as in the non-callback case. This way, unknown callbacks will fail instead of returning valid, but wrong, results.&lt;br /&gt;
&lt;br /&gt;
As explained above, a callback result is something like -+06 80+- (with 06 being used as value of the callback), instead of a regular set-id that would be for example -+04 00+-.&lt;br /&gt;
&lt;br /&gt;
-=Example=-&lt;br /&gt;
&lt;br /&gt;
Suppose you have three different graphics for a wagon:&lt;br /&gt;
* unpowered with no pantograph&lt;br /&gt;
* powered with active pantograph&lt;br /&gt;
* powered with inactive pantograph&lt;br /&gt;
&lt;br /&gt;
Now you want only every other wagon to be powered and have a pantograph, and only the third wagon should have an active pantograph.&lt;br /&gt;
&lt;br /&gt;
Then, your .NFO file might look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~0 * 4 1C 00 00 00&lt;br /&gt;
&lt;br /&gt;
1 * 8 08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// Set wagon to use new sprites, to use callback, and set default visual effect to none&lt;br /&gt;
&lt;br /&gt;
2 * 11 00 00 03 01 1B 12 FD 1E 01 22 40&lt;br /&gt;
&lt;br /&gt;
// Set engine to use callback and default, set wagon&lt;br /&gt;
&lt;br /&gt;
// power&amp;amp;amp;weight;, but *don&amp;#039;t* set to use new sprites&lt;br /&gt;
&lt;br /&gt;
// (no new sprites so we can put a pure callback&lt;br /&gt;
&lt;br /&gt;
// action 2 in its action 3)&lt;br /&gt;
&lt;br /&gt;
3 * 14 00 00 04 01 00 1E 01 22 14 1B 40 00 23 14&lt;br /&gt;
&lt;br /&gt;
4 * 4 01 00 03 04&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
// Cargo-ids 0..2: use above sets&lt;br /&gt;
&lt;br /&gt;
17 * 9 02 00 00 01 01 00 00 00 00&lt;br /&gt;
&lt;br /&gt;
18 * 9 02 00 01 01 01 01 00 01 00&lt;br /&gt;
&lt;br /&gt;
19 * 9 02 00 02 01 01 02 00 02 00&lt;br /&gt;
&lt;br /&gt;
// Cargo-id 3: Show active pantographs only for first powered&lt;br /&gt;
&lt;br /&gt;
// wagon, i.e. the third vehicle in the consist&lt;br /&gt;
&lt;br /&gt;
20 * 14 02 00 03 81 40 00 FF 01 01 00 02 02 02 00&lt;br /&gt;
&lt;br /&gt;
// Cargo-id 4: Show pantographs only on every other wagon&lt;br /&gt;
&lt;br /&gt;
21 * 14 02 00 04 81 40 00 01 01 00 00 01 01 03 00&lt;br /&gt;
&lt;br /&gt;
// Repeat the above for a callback, return the following:&lt;br /&gt;
&lt;br /&gt;
// 8080 for unpowered wagons (i.e. has cargo-id 00)&lt;br /&gt;
&lt;br /&gt;
// 8000 for powered wagons without effects (i.e. cargo-id 01)&lt;br /&gt;
&lt;br /&gt;
// 8034 for powered wagons with sparks (i.e. cargo-id 02)&lt;br /&gt;
&lt;br /&gt;
22 * 14 02 00 05 81 40 00 FF 01 34 80 02 02 00 80&lt;br /&gt;
&lt;br /&gt;
23 * 14 02 00 06 81 40 00 01 01 80 80 01 01 05 00&lt;br /&gt;
&lt;br /&gt;
// Finally switch between callback (06) and cargo-ids (04)&lt;br /&gt;
&lt;br /&gt;
24 * 14 02 00 07 81 0C 00 FF 01 06 00 10 10 04 00&lt;br /&gt;
&lt;br /&gt;
// Define callback for the engine: show sparks only if less&lt;br /&gt;
&lt;br /&gt;
// than two wagons (otherwise third wagon has them)&lt;br /&gt;
&lt;br /&gt;
25 * 14 02 00 08 81 40 10 FF 01 40 80 02 FF 14 80&lt;br /&gt;
&lt;br /&gt;
// And use this in the action 3 for the engine and the&lt;br /&gt;
&lt;br /&gt;
// passenger wagon override&lt;br /&gt;
&lt;br /&gt;
26 * 7 03 00 01 00 00 08 00&lt;br /&gt;
&lt;br /&gt;
27 * 7 03 00 81 1B 00 07 00~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The decision tree of the wagon cargo ID definitions (shown in bold below), read from left to right would look like this:&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
| | |Y, &amp;#039;&amp;#039;&amp;#039;8034&amp;#039;&amp;#039;&amp;#039;|Powered with sparks&lt;br /&gt;
&lt;br /&gt;
| |Y, &amp;#039;&amp;#039;&amp;#039;05&amp;#039;&amp;#039;&amp;#039;: Is third wagon?|&lt;br /&gt;
&lt;br /&gt;
| | |N, &amp;#039;&amp;#039;&amp;#039;8000&amp;#039;&amp;#039;&amp;#039;|Powered without sparks&lt;br /&gt;
&lt;br /&gt;
|Y, &amp;#039;&amp;#039;&amp;#039;06&amp;#039;&amp;#039;&amp;#039;: Is odd wagon?|&lt;br /&gt;
&lt;br /&gt;
| |N, &amp;#039;&amp;#039;&amp;#039;8080&amp;#039;&amp;#039;&amp;#039;|&amp;lt;center&amp;gt;&amp;amp;rarr;&amp;lt;/center&amp;gt;|Unpowered&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;07&amp;#039;&amp;#039;&amp;#039;: Callback?|&lt;br /&gt;
&lt;br /&gt;
| | |Y, &amp;#039;&amp;#039;&amp;#039;01&amp;#039;&amp;#039;&amp;#039;|Active pantograph&lt;br /&gt;
&lt;br /&gt;
| |Y, &amp;#039;&amp;#039;&amp;#039;03&amp;#039;&amp;#039;&amp;#039;: Is third wagon?|&lt;br /&gt;
&lt;br /&gt;
| | |N, &amp;#039;&amp;#039;&amp;#039;02&amp;#039;&amp;#039;&amp;#039;|Inactive pantograph&lt;br /&gt;
&lt;br /&gt;
|N, &amp;#039;&amp;#039;&amp;#039;04&amp;#039;&amp;#039;&amp;#039;: Is odd wagon?|&lt;br /&gt;
&lt;br /&gt;
| |N, &amp;#039;&amp;#039;&amp;#039;00&amp;#039;&amp;#039;&amp;#039;|&amp;lt;center&amp;gt;&amp;amp;rarr;&amp;lt;/center&amp;gt;|No pantograph&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
Notice how all callbacks return something with &amp;amp;quot;80&amp;amp;quot; in the high byte, and all non-callbacks return regular cargo-IDs for the wagons. &amp;amp;nbsp;It&amp;#039;s important that this is true, or otherwise the vehicle either gets no new graphics or the callback is unsuccessful. &amp;amp;nbsp;For the engine, we didn&amp;#039;t set it to use new graphics, so the action 2 entries can all return callback results.&lt;br /&gt;
&lt;br /&gt;
Note that you still have to set the wagon power using [[Action0|action 0]], as well as the callback flags.&lt;/div&gt;</summary>
		<author><name>peter1138</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=632&amp;oldid=prev</id>
		<title>dev%7Cant at 09:18, 21 March 2006</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Callbacks_Tutorial&amp;diff=632&amp;oldid=prev"/>
		<updated>2006-03-21T09:18:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Tutorial on using callbacks&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=Callbacks in Graphics Files=&lt;br /&gt;
&lt;br /&gt;
Since TTDPatch 2.0.1 alpha 11, it is possible to use callbacks, in which the graphics files can influence how TTDPatch features work. This is a lot more sophisticated than simply using action 0 to choose various settings, in that callbacks can use the full capabilities of variational and random action 2 entries.&lt;br /&gt;
&lt;br /&gt;
-=How it works=-&lt;br /&gt;
&lt;br /&gt;
When the patch wants to use the value of certain properties, it can ask the graphics file what value to use, instead of simply looking it up in the table set by action 0. It does this if the corresponding callback bit has been set in the vehicle&amp;#039;s action 0 properties. Then, the following happens:&lt;br /&gt;
* The patch sets the current callback ID, variable 0C, according to what callback it is&lt;br /&gt;
* Then, the patch starts at the vehicle&amp;#039;s action 3 entry and finds the initial action 2 number to use&lt;br /&gt;
* The patch then follows the chain of variational/random action 2 entries&lt;br /&gt;
* The value of the final action 2 is used as result for the callback&lt;br /&gt;
&lt;br /&gt;
Because callbacks are different from regular vehicle graphics, the last action 2 must return a high byte of FF, which is invalid for regular graphics. &amp;amp;nbsp;Therefore, at least one action 2 in the chain must check the variable 0C, to decide whether this is a callback or the determination of graphics.&lt;br /&gt;
&lt;br /&gt;
-=How to define callbacks=-&lt;br /&gt;
&lt;br /&gt;
There are several things you have to do to get callbacks to work.&lt;br /&gt;
# Set the callback bit in the [[Action0|action 0]] property for the vehicle which should use callbacks (props 1E, 17, 12 or 14 depending on vehicle type)&lt;br /&gt;
# Set a default for the value that the callback modifies, e.g. set prop 07 when using the load amount callback&lt;br /&gt;
# Define an [[Action3|action 3]] for the vehicle if it doesn&amp;#039;t have one already&lt;br /&gt;
# Add a [[VariationalAction2|variational action 2]] that checks the callback variable 0C for the value of the callback. See the description of a variational action 2 to find what values those are.&lt;br /&gt;
# This variational action 2 has to return a callback result when in a callback, or a regular set-id when not in a callback&lt;br /&gt;
&lt;br /&gt;
As explained above, a callback result is something like -+06 FF+- (with 06 being used as value of the callback), instead of a regular set-id that would be for example -+04 00+-.&lt;br /&gt;
&lt;br /&gt;
-=Example=-&lt;br /&gt;
&lt;br /&gt;
Suppose you have three different graphics for a wagon:&lt;br /&gt;
* unpowered with no pantograph&lt;br /&gt;
* powered with active pantograph&lt;br /&gt;
* powered with inactive pantograph&lt;br /&gt;
&lt;br /&gt;
Now you want only every other wagon to be powered and have a pantograph, and only the third wagon should have an active pantograph.&lt;br /&gt;
&lt;br /&gt;
Then, your .NFO file might look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;~pp~0 * 4 1C 00 00 00&lt;br /&gt;
&lt;br /&gt;
1 * 8 08 02 xx xx xx xx 00 00&lt;br /&gt;
&lt;br /&gt;
// Set wagon to use new sprites, to use callback, and set default visual effect to none&lt;br /&gt;
&lt;br /&gt;
2 * 11 00 00 03 01 1B 12 FD 1E 01 22 40&lt;br /&gt;
&lt;br /&gt;
// Set engine to use callback and default, set wagon&lt;br /&gt;
&lt;br /&gt;
// power&amp;amp;amp;weight;, but *don&amp;#039;t* set to use new sprites&lt;br /&gt;
&lt;br /&gt;
// (no new sprites so we can put a pure callback&lt;br /&gt;
&lt;br /&gt;
// action 2 in its action 3)&lt;br /&gt;
&lt;br /&gt;
3 * 14 00 00 04 01 00 1E 01 22 14 1B 40 00 23 14&lt;br /&gt;
&lt;br /&gt;
4 * 4 01 00 03 04&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
&lt;br /&gt;
// Cargo-ids 0..2: use above sets&lt;br /&gt;
&lt;br /&gt;
17 * 9 02 00 00 01 01 00 00 00 00&lt;br /&gt;
&lt;br /&gt;
18 * 9 02 00 01 01 01 01 00 01 00&lt;br /&gt;
&lt;br /&gt;
19 * 9 02 00 02 01 01 02 00 02 00&lt;br /&gt;
&lt;br /&gt;
// Cargo-id 3: Show active pantographs only for first powered&lt;br /&gt;
&lt;br /&gt;
// wagon, i.e. the third vehicle in the consist&lt;br /&gt;
&lt;br /&gt;
20 * 14 02 00 03 81 40 00 FF 01 01 00 02 02 02 00&lt;br /&gt;
&lt;br /&gt;
// Cargo-id 4: Show pantographs only on every other wagon&lt;br /&gt;
&lt;br /&gt;
21 * 14 02 00 04 81 40 00 01 01 00 00 01 01 03 00&lt;br /&gt;
&lt;br /&gt;
// Repeat the above for a callback, return the following:&lt;br /&gt;
&lt;br /&gt;
// FF40 for unpowered wagons (i.e. has cargo-id 00)&lt;br /&gt;
&lt;br /&gt;
// FF00 for powered wagons without effects (i.e. cargo-id 01)&lt;br /&gt;
&lt;br /&gt;
// FF34 for powered wagons with sparks (i.e. cargo-id 02)&lt;br /&gt;
&lt;br /&gt;
22 * 14 02 00 05 81 40 00 FF 01 34 FF 02 02 00 FF&lt;br /&gt;
&lt;br /&gt;
23 * 14 02 00 06 81 40 00 01 01 40 FF 01 01 05 00&lt;br /&gt;
&lt;br /&gt;
// Finally switch between callback (06) and cargo-ids (04)&lt;br /&gt;
&lt;br /&gt;
24 * 14 02 00 07 81 0C 00 FF 01 06 00 10 10 04 00&lt;br /&gt;
&lt;br /&gt;
// Define callback for the engine: show sparks only if less&lt;br /&gt;
&lt;br /&gt;
// than two wagons (otherwise third wagon has them)&lt;br /&gt;
&lt;br /&gt;
25 * 14 02 00 08 81 40 10 FF 01 40 FF 02 FF 14 FF&lt;br /&gt;
&lt;br /&gt;
// And use this in the action 3 for the engine and the&lt;br /&gt;
&lt;br /&gt;
// passenger wagon override&lt;br /&gt;
&lt;br /&gt;
26 * 7 03 00 01 00 00 08 00&lt;br /&gt;
&lt;br /&gt;
27 * 7 03 00 81 1B 00 07 00~/pp~&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The decision tree of the wagon cargo ID definitions (shown in bold below), read from left to right would look like this:&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
| | |Y, &amp;#039;&amp;#039;&amp;#039;FF34&amp;#039;&amp;#039;&amp;#039;|Powered with sparks&lt;br /&gt;
&lt;br /&gt;
| |Y, &amp;#039;&amp;#039;&amp;#039;05&amp;#039;&amp;#039;&amp;#039;: Is third wagon?|&lt;br /&gt;
&lt;br /&gt;
| | |N, &amp;#039;&amp;#039;&amp;#039;FF00&amp;#039;&amp;#039;&amp;#039;|Powered without sparks&lt;br /&gt;
&lt;br /&gt;
|Y, &amp;#039;&amp;#039;&amp;#039;06&amp;#039;&amp;#039;&amp;#039;: Is odd wagon?|&lt;br /&gt;
&lt;br /&gt;
| |N, &amp;#039;&amp;#039;&amp;#039;FF40&amp;#039;&amp;#039;&amp;#039;|&amp;lt;center&amp;gt;&amp;amp;rarr;&amp;lt;/center&amp;gt;|Unpowered&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;07&amp;#039;&amp;#039;&amp;#039;: Callback?|&lt;br /&gt;
&lt;br /&gt;
| | |Y, &amp;#039;&amp;#039;&amp;#039;01&amp;#039;&amp;#039;&amp;#039;|Active pantograph&lt;br /&gt;
&lt;br /&gt;
| |Y, &amp;#039;&amp;#039;&amp;#039;03&amp;#039;&amp;#039;&amp;#039;: Is third wagon?|&lt;br /&gt;
&lt;br /&gt;
| | |N, &amp;#039;&amp;#039;&amp;#039;02&amp;#039;&amp;#039;&amp;#039;|Inactive pantograph&lt;br /&gt;
&lt;br /&gt;
|N, &amp;#039;&amp;#039;&amp;#039;04&amp;#039;&amp;#039;&amp;#039;: Is odd wagon?|&lt;br /&gt;
&lt;br /&gt;
| |N, &amp;#039;&amp;#039;&amp;#039;00&amp;#039;&amp;#039;&amp;#039;|&amp;lt;center&amp;gt;&amp;amp;rarr;&amp;lt;/center&amp;gt;|No pantograph&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
Notice how all callbacks return something with FF in the high byte, and all non-callbacks return regular cargo-IDs for the wagons. &amp;amp;nbsp;It&amp;#039;s important that this is true, or otherwise the vehicle either gets no new graphics or the callback is unsuccessful. &amp;amp;nbsp;For the engine, we didn&amp;#039;t set it to use new graphics, so the action 2 entries can all return callback results.&lt;br /&gt;
&lt;br /&gt;
Note that you still have to set the wagon power using [[Action0|action 0]], as well as the callback flags.&lt;/div&gt;</summary>
		<author><name>dev%7Cant</name></author>
	</entry>
</feed>