<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.tt-wiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=FooBar</id>
	<title>TTWiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://www.tt-wiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=FooBar"/>
	<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/wiki/Special:Contributions/FooBar"/>
	<updated>2026-04-28T22:17:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Dutch_Trainset_2&amp;diff=9577</id>
		<title>Dutch Trainset 2</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Dutch_Trainset_2&amp;diff=9577"/>
		<updated>2015-09-19T11:59:41Z</updated>

		<summary type="html">&lt;p&gt;FooBar: remove alpha1 info due to outdated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{DutchSets}}&lt;br /&gt;
&lt;br /&gt;
[[Image:DTSnew3.PNG|center|link=Dutch Trainset 2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dutch Trainset 2&#039;&#039;&#039; is a fully reworked version of the original [[Dutch Trainset]] for OpenTTD. A lot of trains were added and the graphics of many existing trains were improved and expanded with different liveries. Furthermore we built in native support for new cargoes provided by industry sets and fixed a number of bugs that were present in the first version of the trainset. We went way back to the dawn of Dutch railroads in 1839 and brought back Arend. We went ahead in time and give you the V250 Albatross. And most of everything in between, including the metros of Amsterdam and Rotterdam.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you&#039;re looking for some details on [[Dutch Trainset 2/Handbook|how to play]] with the set or want to know what [[Dutch Trainset 2/Vehicles|vehicles]] are available, please find separate pages about that in the menu at the right.&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
Dutch Trainset 2 is available from the OpenTTD Online Content. If for some reason you want a manual download or older release, you can get that from the [http://bundles.openttdcoop.org/dutchtrains/releases/LATEST/ DevZone].&lt;br /&gt;
&lt;br /&gt;
The DevZone also provides [http://bundles.openttdcoop.org/dutchtrains/push/LATEST/ nightly builds], in case you want to test out the latest and cannot wait for the next release.&lt;br /&gt;
&lt;br /&gt;
Finally, the [http://dev.openttdcoop.org/projects/dutchtrains/repository source code] (licensed GPLv2+) is available from the DevZone as well.&lt;br /&gt;
&lt;br /&gt;
[[Image:Dutchtrains.png|frame|center|All trains and wagons in 2.0.0-alpha1]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reporting bugs ==&lt;br /&gt;
If you have any issue with this trainset, please report it to the [http://dev.openttdcoop.org/projects/dutchtrains/issues issue tracker] or the [http://www.tt-forums.net/viewtopic.php?t=59353 forum topic].&lt;br /&gt;
&lt;br /&gt;
Always included a detailed description of the bug, preferrably with&lt;br /&gt;
screenshot and savegame. Also state the exact game version you&#039;re using, &lt;br /&gt;
as well as the version of this NewGRF.&lt;br /&gt;
&lt;br /&gt;
If you have a savegame that includes NewGRFs not available on OpenTTD&#039;s &lt;br /&gt;
Online Content, then please try to reproduce the bug in a new game &lt;br /&gt;
which has all NewGRFs easily accessible.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using a patched version of the game, please try to reproduce&lt;br /&gt;
the bug on an official game build. If you can&#039;t reproduce the bug, then&lt;br /&gt;
don&#039;t report it here but in the forum topic of the patch(pack) instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Dutch Trainset 2/Handbook|Handbook]]&lt;br /&gt;
* [[Dutch Trainset 2/Vehicles|List of vehicles]]&lt;br /&gt;
* [[Dutch Trainset|First Dutch Trainset]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
; Forum&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?t=59353 Release topic]&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?f=26&amp;amp;t=5033 Development topic]&lt;br /&gt;
; Downloads&lt;br /&gt;
* [http://bundles.openttdcoop.org/dutchtrains/releases/LATEST/ Releases] (also on the Online Content)&lt;br /&gt;
* [http://bundles.openttdcoop.org/dutchtrains/push/LATEST/ Nightlies]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/dutchtrains/repository Source]&lt;br /&gt;
; Other&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/dutchtrains/issues Issue tracker]&lt;br /&gt;
* [https://docs.google.com/spreadsheet/ccc?key=0Anuwxjk8DGu8dFZ2NlVocDh1TnVGaER6UWp4NzJ2enc Infosheet]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Parameters&amp;diff=9114</id>
		<title>NMLTutorial/Parameters</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Parameters&amp;diff=9114"/>
		<updated>2014-08-02T19:48:14Z</updated>

		<summary type="html">&lt;p&gt;FooBar: /* Enumeration parameter */ example was missing type&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
NewGRF Parameters in NML are part of the grf block&lt;br /&gt;
&amp;lt;pre&amp;gt;grf {&lt;br /&gt;
	grfid: &amp;quot;NML\FF&amp;quot;;&lt;br /&gt;
	name: string(STR_GRF_NAME);&lt;br /&gt;
	desc: string(STR_GRF_DESC);&lt;br /&gt;
	version: 1;&lt;br /&gt;
	min_compatible_version: 0;&lt;br /&gt;
	param &amp;lt;num&amp;gt; {&lt;br /&gt;
		&amp;lt;name&amp;gt; {&lt;br /&gt;
			name: string(STR_PARAM_NAME_ECONOMIES);&lt;br /&gt;
			desc: string(STR_PARAM_DESC_ECONOMIES);&lt;br /&gt;
			&amp;lt;specifics&amp;gt;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; is the name the parameter is referenced further within the grf to read this parameter. &amp;lt;num&amp;gt; is the number of this parameter. The &amp;lt;num&amp;gt; parameter is optional and not needed when parameters are not re-ordered throughout versions. It can be used to keep the meaning of a specific NewGRF parameter while re-ordering the code. The meaning of a NewGRF parameter should should remain constant throughout versions of the same NewGRF or the NewGRF might become incompatible with previous versions of the same NewGRF (thus you&#039;d need to change min_compatible_version if you change the meaning of the parameters at &amp;lt;num&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Parameter types ==&lt;br /&gt;
NML knows three different types of parameters, boolean, numeric ones and enumerations:&lt;br /&gt;
&lt;br /&gt;
=== Boolean parameter ===&lt;br /&gt;
The boolean parameter is the easiest as it requires no further definitions besides the name and description. Optionally a single parameter can contain several boolean parameter values, each using a single bit, thus saving in the number of externally visible NewGRF parameters.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
param 3 { // 3rd parameter of the NewGRF&lt;br /&gt;
	param_bool_1 { // 1st boolean value&lt;br /&gt;
		name: string(STR_PARAM_NAME_DEBUG);&lt;br /&gt;
		desc: string(STR_PARAM_DESC_DEBUG);&lt;br /&gt;
		type: bool;&lt;br /&gt;
		bit:  1; // uses 1st bit&lt;br /&gt;
	}&lt;br /&gt;
	param_bool_2 { // 2nd boolean value&lt;br /&gt;
		name: string(STR_PARAM_NAME_DEBUG);&lt;br /&gt;
		desc: string(STR_PARAM_DESC_DEBUG);&lt;br /&gt;
		type: bool;&lt;br /&gt;
		bit:  2; // uses 2nd bit&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Numeric parameter ===&lt;br /&gt;
&lt;br /&gt;
The numeric parameter allows to directly input an (integer) number. It needs to have a minimum and maximum value given and optionally - and usually a good idea - a default value for the parameter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
param 1 {&lt;br /&gt;
	param_depot_year {&lt;br /&gt;
		type: int;&lt;br /&gt;
		name: string(STR_PARAM_DEPOTYEAR);&lt;br /&gt;
		desc: string(STR_PARAM_DEPOTYEAR_DESC);&lt;br /&gt;
		min_value: 0;&lt;br /&gt;
		max_value: 5000000;&lt;br /&gt;
		def_value: 1975;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enumeration parameter ===&lt;br /&gt;
&lt;br /&gt;
The enumeration parameter basically is a numeric parameter where the single values have (additionally) a string attached to describe their meaning. Not all values need a string description, but it usually is a good idea to do this consistently&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
param 0 {&lt;br /&gt;
	economy {&lt;br /&gt;
		type: int;&lt;br /&gt;
		name: string(STR_PARAM_NAME_ECONOMIES);&lt;br /&gt;
		desc: string(STR_PARAM_DESC_ECONOMIES);&lt;br /&gt;
		min_value: 0;&lt;br /&gt;
		max_value: 1;&lt;br /&gt;
		def_value: 0;&lt;br /&gt;
		names: {&lt;br /&gt;
			0: string(STR_PARAM_VALUE_ECONOMIES_TEST_ECONOMY);&lt;br /&gt;
			1: string(STR_PARAM_VALUE_ECONOMIES_HARD_ECONOMY);&lt;br /&gt;
		};&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Train four part refit|Train recolour}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Version_check&amp;diff=9113</id>
		<title>NMLTutorial/Version check</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Version_check&amp;diff=9113"/>
		<updated>2014-08-02T19:45:49Z</updated>

		<summary type="html">&lt;p&gt;FooBar: /* If block */ is possible inside item block&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
Version checks are useful if you use certain features in your NewGRF that are not available in older versions of the game (or only available in one game and not the other, both TTDPatch and OpenTTD have some features that are not available in the other). If your NewGRF relies on a certain feature, you must have your NewGRF disable itself and issue an error message. If your NewGRF can work without a certain feature, you can use a version check to disable that part of your NewGRF while keeping the rest.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== If block ==&lt;br /&gt;
The basis of every version check is an if block&amp;lt;ref&amp;gt;Actually &#039;&#039;if&#039;&#039; is not a block but a language construct, but for the purpose of understanding it you can consider it a block.&amp;lt;/ref&amp;gt;. The if blocks allows to check if a certain condition (for instance based on a [http://newgrf-specs.tt-wiki.net/wiki/NML:General#General_variables general variable] or a GRF parameter) is true. If the condition is true, the contents inside the switch block is executed, otherwise it&#039;s skipped.&lt;br /&gt;
&lt;br /&gt;
An if block looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
if (&amp;lt;condition&amp;gt;) {&lt;br /&gt;
	&amp;lt;code_executed_when_condition_true&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;condition&amp;gt;&amp;lt;/code&amp;gt; usually is a [http://newgrf-specs.tt-wiki.net/wiki/NML:General#General_variables general variable] or GRF parameter compared against a static value, a different variable or a different parameter. The &amp;lt;code&amp;gt;&amp;lt;code_executed_when_condition_true&amp;gt;&amp;lt;/code&amp;gt; can be anything you would normally write in an NML file, so you can have one or more blocks inside an if block. However, you cannot have if blocks inside other blocks (except other if or else blocks and item blocks). The code inside the if block is only executed when the &amp;lt;code&amp;gt;&amp;lt;condition&amp;gt;&amp;lt;/code&amp;gt; is true.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;condition&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
The comparison itself is made using a &#039;&#039;comparison operator&#039;&#039; which you may already know from different programming languages. Here&#039;s a table with the comparison operators available in NML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Indeed, I cannot be bothered to remember the mediawiki table syntax while html tables work just fine. Live with it, or change it yourself --&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;       Symbol       &amp;lt;/th&amp;gt;&amp;lt;th&amp;gt; Description&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; ==    &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Is equal to &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;code&amp;gt;!=    &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Is not equal to &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; &amp;amp;lt;  &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Is less than &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; &amp;amp;lt;= &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Is less than or equal to &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; &amp;amp;gt;  &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Is bigger than &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; &amp;amp;gt;= &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Is bigger than or equal to &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So for example if you want to check if A is bigger than or equal to B:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if (A &amp;gt;= B) {&lt;br /&gt;
	//whatever happens when A is bigger than or equal to B goes here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In case you make multiple comparisons, you can either nest multiple if blocks or combine those comparisons in a single &amp;lt;code&amp;gt;&amp;lt;condition&amp;gt;&amp;lt;/code&amp;gt; using the so-called logical operators. The logical operators can work with boolean values (true or false) to combine multiple comparisons. Here&#039;s a table with the logical operators available in NML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Again with the html table --&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;       Symbol    &amp;lt;/th&amp;gt;&amp;lt;th&amp;gt; Description&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; &amp;amp;&amp;amp; &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Logical AND. True if both sides are true. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; || &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Logical OR. True if either side (or both) are true. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So for instance if you want to check if A is bigger than or equal to B while at the same time C is not equal to D:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if ((A &amp;gt;= B) &amp;amp;&amp;amp; (C != D)) {&lt;br /&gt;
	//whatever happens when A is bigger than or equal to B and C is not equal to D goes here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Things between brackets is evaluated first before combining it with things outside these brackets this makes sure that a certain sub-condition is evaluated to true/false before logically combining it (the comparison operators can compare just about anything, but the logical operators can only combine boolean values). In some cases you do not need all brackets, which has something to do with &#039;&#039;operator precedence&#039;&#039;; we will not bother you with that right now. When in doubt, it doesn&#039;t hurt to use more brackets than actually needed (as long as they are in the correct places of course!) and they work very similar to brackets in mathematics.&lt;br /&gt;
&lt;br /&gt;
=== else ===&lt;br /&gt;
If besides something you want to do when the condition is true, you also want to do something else when the condition is &#039;&#039;not&#039;&#039; true, you can add an else block behind the if block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
if (&amp;lt;condition&amp;gt;) {&lt;br /&gt;
	&amp;lt;code_executed_when_condition_true&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
	&amp;lt;code_executed_when_condition_false&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code in the if block will only be executed when the condition is true. The code in the else block is only executed when the condition (for the if block) is not true. An else block must be written directly behind the closing curly bracket of the if block, with no other code inbetween.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also combine an else and if block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
if (&amp;lt;condition&amp;gt;) {&lt;br /&gt;
	&amp;lt;code_executed_when_condition_true&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
else if (&amp;lt;other_condition&amp;gt;) {&lt;br /&gt;
	&amp;lt;code_executed_when_other_condition_true&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
	&amp;lt;code_executed_when_both_conditions_false&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this, if the first comparison is false, you make a different comparison and when even that is false you get the &#039;&#039;else&#039;&#039;. You can have as many else if blocks between an if block and an else block as you want. Again no other code may appear inbetween those blocks (but of course you can have any code you like inside these blocks).&lt;br /&gt;
&lt;br /&gt;
== Error function ==&lt;br /&gt;
The error function allows to issue notices, warnings, errors and fatal error messages. The fatal type also disables the NewGRF immediately. The general syntax of an error block is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
error(&amp;lt;level&amp;gt;, &amp;lt;message&amp;gt; [, &amp;lt;extra_text&amp;gt; [, &amp;lt;parameter1&amp;gt; [, &amp;lt;parameter2&amp;gt; ]]])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error function may appear outside blocks, inside if or else blocks, but not inside other blocks.&lt;br /&gt;
&lt;br /&gt;
The error &amp;lt;code&amp;gt;&amp;lt;level&amp;gt;&amp;lt;/code&amp;gt; can be any of:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;       Constant       &amp;lt;/th&amp;gt;&amp;lt;th&amp;gt; Description &amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; NOTICE  &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Add a notice in the NewGRF status window, continue loading the grf. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; WARNING &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Add a warning in the NewGRF status window, prefixed with &amp;quot;Warning: &amp;quot;, continue loading the grf. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; ERROR   &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Add a error message in the NewGRF status window, prefixed with &amp;quot;Error: &amp;quot;, continue loading the grf. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;code&amp;gt; FATAL   &amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; Add a error message in the NewGRF status window, prefixed with &amp;quot;Error: &amp;quot;, abort loading the grf, also give the error message in a red popup box ingame. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;message&amp;gt;&amp;lt;/code&amp;gt; can be one of seven predefined messages (see the [http://newgrf-specs.tt-wiki.net/wiki/NML:Error NML Documentation]) or a custom string (using the &amp;lt;code&amp;gt;string()&amp;lt;/code&amp;gt; function). &amp;lt;code&amp;gt;&amp;lt;extra_text&amp;gt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;lt;parameter1&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;parameter2&amp;gt;&amp;lt;/code&amp;gt; are optional. &amp;lt;code&amp;gt;&amp;lt;extra_text&amp;gt;&amp;lt;/code&amp;gt; must be used when one of the predefined messages is used and can either be a string from the language file or a literal quoted string in the NML code. &amp;lt;code&amp;gt;&amp;lt;parameter1&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;parameter2&amp;gt;&amp;lt;/code&amp;gt; can be used in custom strings and when defined must be the identifier of a GRF parameter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So if you want to disable your NewGRF with an error message, you use the &amp;lt;code&amp;gt;FATAL&amp;lt;/code&amp;gt; error level combined with either a predefined string or a error message of your own. If you just want a message without disabling your NewGRF, use one of the other error levels.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Version checks in NML are actually pretty straight forward.&lt;br /&gt;
&lt;br /&gt;
NML provides the [http://newgrf-specs.tt-wiki.net/wiki/NML:General#General_variables general variables] &amp;lt;code&amp;gt;openttd_version&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ttdpatch_version&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ttd_platform&amp;lt;/code&amp;gt; to do version and game platform checks. Concerning &amp;lt;code&amp;gt;openttd_version&amp;lt;/code&amp;gt; checks the built-in [http://newgrf-specs.tt-wiki.net/wiki/NML:Builtin_functions function] &amp;lt;code&amp;gt;version_openttd()&amp;lt;/code&amp;gt; comes in very handy as it provides an easy means to specify the version instead of manually constructing the version number corresponding to a specific version.&lt;br /&gt;
&lt;br /&gt;
=== Check game platform ===&lt;br /&gt;
Checking for the OpenTTD platform is simply done by an if block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if (ttd_platform != PLATFORM_OPENTTD) {&lt;br /&gt;
	error(FATAL, string(STR_REQUIRES_OPENTTD));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The string &amp;lt;code&amp;gt;STR_REQUIRES_OPENTTD&amp;lt;/code&amp;gt; will hold an error message telling the (TTDPatch) user that OpenTTD is needed for this NewGRF. Note that you cannot use the predefined &amp;lt;code&amp;gt;REQUIRES_OPENTTD&amp;lt;/code&amp;gt; as this string doesn&#039;t exist in TTDPatch!&lt;br /&gt;
&lt;br /&gt;
Similarly, if you want to check for the TTDPatch platform:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if (ttd_platform != PLATFORM_TTDPATCH) {&lt;br /&gt;
	error(FATAL, REQUIRES_TTDPATCH, string(STR_VERSION_TTDPATCH));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time you &#039;&#039;can&#039;&#039; use the predefined &amp;lt;code&amp;gt;REQUIRES_TTDPATCH&amp;lt;/code&amp;gt; string, as this string does exist in OpenTTD.&lt;br /&gt;
&lt;br /&gt;
=== Check game version and die ===&lt;br /&gt;
If you NewGRF requires a specific feature to work, disable it if a game version is used that doesn&#039;t have that version.&lt;br /&gt;
&lt;br /&gt;
This is a check to disable the NewGRF if a certain OpenTTD feature is not found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
//parameterized spritelayout is only supported since OpenTTD 1.2.0 r22723&lt;br /&gt;
if (version_openttd(1,2,0,22723) &amp;gt; openttd_version) {&lt;br /&gt;
	error(FATAL, REQUIRES_OPENTTD, &amp;quot;1.2.0 (r22723)&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Check game version and conditionally use more advanced features ===&lt;br /&gt;
If your NewGRF doesn&#039;t need a specific feature to work, you can disable that version for older versions.&lt;br /&gt;
&lt;br /&gt;
This is a check for a specific OpenTTD (and similarily TTDPatch) version:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
/* Only define cargo_age_period when that property is available */&lt;br /&gt;
if (openttd_version &amp;gt; version_openttd(1, 2, 0, 22713)) {&lt;br /&gt;
	item (FEAT_TRAINS, my_engine) {&lt;br /&gt;
		property {&lt;br /&gt;
			cargo_age_period: 200;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Combining platform and version checks ===&lt;br /&gt;
You must not check the OpenTTD version in TTDPatch or the TTDPatch version in OpenTTD. TTDPatch doesn&#039;t have any useful information for the OpenTTD version and similarly OpenTTD doesn&#039;t have useful information for the TTDPatch version.&lt;br /&gt;
&lt;br /&gt;
You can nest both checks above using multiple if blocks. It&#039;s also possible to combine these checks into a single block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
/* Long date string codes require OpenTTD &amp;gt; 1.2.0 or r22780 */&lt;br /&gt;
if (ttd_platform != PLATFORM_OPENTTD || openttd_version &amp;lt; version_openttd(1, 2, 0, 22780)) {&lt;br /&gt;
	error(FATAL, REQUIRES_OPENTTD, string(STR_MIN_OPENTTD_VERSION));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Object graphics|Object slopes}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Conclusion&amp;diff=9112</id>
		<title>NMLTutorial/Conclusion</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Conclusion&amp;diff=9112"/>
		<updated>2014-07-23T10:49:22Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Dutch Trainset is no longer planned&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
There you are, the very end of the NML tutorial. It&#039;s been a pleasure to write and I hope learned a thing or two. If you still think NML is not for you, maybe try your luck at [[GraphicsTutorial|drawing graphics]] instead. If you think NML is not too bad, then I hope to see a nice NewGRF from you any time soon!&lt;br /&gt;
&lt;br /&gt;
If you have any further questions on how to make your NewGRF in NML that are not addressed in the tutorial, feel free to ask them on the [http://www.tt-forums.net/viewforum.php?f=68 forums] or on [irc://irc.oftc.net/openttdcoop.devzone irc]. There always will be people that can help you out. And don&#039;t forget the [http://newgrf-specs.tt-wiki.net/wiki/NML:Main NML Documentation] itself. From here on, you should refer to that instead of this tutorial. Try to use it as much as possible to get familiar with it. I can&#039;t write NML without the NML Documentation, so you surely can&#039;t either.&lt;br /&gt;
&lt;br /&gt;
Below you&#039;ll find a list of NML project with a public (and open) source. Feel free to browse them for inspiration or not having to reinvent the wheel, but respect the licenses these sources come with. Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:FooBar|FooBar]] 11:30, 29 August 2011 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== List of open source NML projects ==&lt;br /&gt;
Below is an alphabetical list of open source NML projects. If your NML project is open source and not listed here, feel free to add it.&lt;br /&gt;
&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/ce-tracks/ Central European Railway Track Set]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/cets Central European Train Set]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/dutchroadfurniture Dutch Road Furniture]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/dutchtrains Dutch Trains 2]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/dutchtramset Dutch Tram Set]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/firs FIRS Industry Replacement Set]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/foobarstramtracks FooBar&#039;s Tram Tracks]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/manindu Manual Industries]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/narvs North American Road Vehicle Set]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/airportsplus OpenGFX+ Airports]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/ogfx-industries OpenGFX+ Industries]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/ogfx-landscape OpenGFX+ Landscape]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/ogfx-rv OpenGFX+ Road Vehicles]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/ogfx-trains OpenGFX+ Trains]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/swedishrails Swedish Rails]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Object slopes||}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Releasing_a_NewGRF&amp;diff=8545</id>
		<title>Releasing a NewGRF</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Releasing_a_NewGRF&amp;diff=8545"/>
		<updated>2012-08-27T09:16:23Z</updated>

		<summary type="html">&lt;p&gt;FooBar: complete page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;So you&#039;ve made yourself a NewGRF and want to release it to the public. How do you go about doing that?&lt;br /&gt;
&lt;br /&gt;
== Write a ReadMe ==&lt;br /&gt;
While most people will never read your readme, it&#039;s still useful to write one. If only to let people know who made the NewGRF, how they can be contacted, and if they&#039;re allowed to use bits of it for something else (i.e. a license, more on that later). Generally a readme also includes some information on what the NewGRF does and how it must be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It&#039;s useful to write your readme in plain text format. That way it can be opened in OpenTTD&#039;s ingame viewer, for easy access. There&#039;s a [[User:FooBar/Generic NewGRF Readme|readme template]] available that you can use as the basis for your own readme.&lt;br /&gt;
&lt;br /&gt;
== Choose a license ==&lt;br /&gt;
If you don&#039;t choose a license, in most countries your work will be automatically protected by copyright law. This means that nobody may use parts of your work for something else without prior permission. By applying a license to your work, you can grant certain permissions so that people don&#039;t have to ask every time. That way others can use bits of your work in their own to for instance improve compatibility between both.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
planetmaker&#039;s written an interesting [http://blog.openttdcoop.org/2011/07/16/copyright-and-licenses-permission-to-what-actually/ article on the subject of licensing]. It&#039;s a recommended read if you&#039;re not sure what license to apply to your work.&lt;br /&gt;
&lt;br /&gt;
== Bundle your work ==&lt;br /&gt;
Once you have a NewGRF, a ReadMe and a License, you want to bundle those. It&#039;s useful to combine all three in a TAR file. OpenTTD can read TAR files without the need for extracting them. That way NewGRF, ReadMe and License will always stay together. Also BaNaNaS accepts TAR files. TTDPatch users can easily extract them, as the TAR format is widely supported by file compression tools. Note that the TAR format doesn&#039;t use compression, so if you want to reduce filesize you can furthermore zip the TAR file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In case you used the [http://dev.openttdcoop.org/ #openttdcoop DevZone] you can tag a revision in your repository as a release. The DevZone will then automatically build a release bundle which you can retrieve from [http://bundles.openttdcoop.org/]. It&#039;s recommended to use this bundle for the next step instead of your own build, to make sure all downloads are the same.&lt;br /&gt;
&lt;br /&gt;
== Uploading the bundle ==&lt;br /&gt;
To make your NewGRF easily accessible to everyone, you certainly would want to upload it to OpenTTD&#039;s Online Content service. For this you go to [http://bananas.openttd.org/] and click the Manager tab. You&#039;re asked to login with your OpenTTD account (which is the same as for the OpenTTD bug tracker and the OpenTTD wiki) or create one if you don&#039;t have one. Note that this is different from your TT-Forums (or TT-Wiki) account. Please read the Terms of Service carefully, which also state what files to upload exactly. From the Manager tab choose to Upload New and complete the fields.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to the Online Content service you may also want to host your NewGRF bundle elsewhere. This will both serve as a backup and aid TTDPatch users as it&#039;s a bit weird for them to get their grfs from the OpenTTD service. The TT-Forums are suitable for hosting your NewGRF in an attachment. If you used an online collaboration platform like the [http://dev.openttdcoop.org/ #openttdcoop DevZone] you can use that as additional hosting for your NewGRF.&lt;br /&gt;
&lt;br /&gt;
== Letting the world know ==&lt;br /&gt;
Certainly you will want to make a post in the TT-Forums [http://www.tt-forums.net/viewforum.php?f=67 Graphics Releases forum]. Write a few words about your NewGRF, add a screenshot and provide a pointer to the download location. You can very well use this post to host your NewGRF in an attachment.&lt;br /&gt;
&lt;br /&gt;
Additinally, advertise your NewGRF on [http://grfcrawler.tt-forums.net/ GRFCrawler]. You&#039;re logged in there automatically if you&#039;re logged in to TT-Forums.&lt;br /&gt;
&lt;br /&gt;
== Providing the source ==&lt;br /&gt;
This step is only required if you&#039;ve chosen a license that requires you to provide the source, like the GPL. In case of the #openttdcoop DevZone or similar, your source repository will qualify as &amp;quot;providing the source&amp;quot;. In other cases you have to make a source bundle. This then includes the &amp;quot;preferred files to make edits to the work&amp;quot;. Upload the source bundle somewhere. Maybe use the TT-Forums topic for it if your source isn&#039;t too big, otherwise find reliable hosting elsewhere. Of course you can also hide behind the &amp;quot;three year written offer&amp;quot;, but this will only provoke people requesting the source even if they don&#039;t need it, resulting you into having to make the source bundle and upload it somewhere anyways.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Releasing_a_NewGRF&amp;diff=8544</id>
		<title>Releasing a NewGRF</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Releasing_a_NewGRF&amp;diff=8544"/>
		<updated>2012-08-27T08:54:37Z</updated>

		<summary type="html">&lt;p&gt;FooBar: intermediate save&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;So you&#039;ve made yourself a NewGRF and want to release it to the public. How do you go about doing that?&lt;br /&gt;
&lt;br /&gt;
== Write a ReadMe ==&lt;br /&gt;
While most people will never read your readme, it&#039;s still useful to write one. If only to let people know who made the NewGRF, how they can be contacted, and if they&#039;re allowed to use bits of it for something else (i.e. a license, more on that later). Generally a readme also includes some information on what the NewGRF does and how it must be used.&lt;br /&gt;
&lt;br /&gt;
It&#039;s useful to write your readme in plain text format. That way it can be opened in OpenTTD&#039;s ingame viewer, for easy access. There&#039;s a [[User:FooBar/Generic NewGRF Readme|readme template]] available that you can use as the basis for your own readme.&lt;br /&gt;
&lt;br /&gt;
== Choose a license ==&lt;br /&gt;
If you don&#039;t choose a license, in most countries your work will be automatically protected by copyright law. This means that nobody may use parts of your work for something else without prior permission. By applying a license to your work, you can grant certain permissions so that people don&#039;t have to ask every time. That way others can use bits of your work in their own to for instance improve compatibility between both.&lt;br /&gt;
&lt;br /&gt;
planetmaker&#039;s written an interesting [http://blog.openttdcoop.org/2011/07/16/copyright-and-licenses-permission-to-what-actually/ article on the subject of licensing]. It&#039;s a recommended read if you&#039;re not sure what license to apply to your work.&lt;br /&gt;
&lt;br /&gt;
== Bundle your work ==&lt;br /&gt;
Once you have a NewGRF, a ReadMe and a License, you want to bundle those. It&#039;s useful to combine all three in a TAR file. OpenTTD can read TAR files without the need for extracting them. That way NewGRF, ReadMe and License will always stay together. Also BaNaNaS accepts TAR files. TTDPatch users can easily extract them, as the TAR format is widely supported by file compression tools. Note that the TAR format doesn&#039;t use compression, so if you want to reduce filesize you can furthermore zip the TAR file.&lt;br /&gt;
&lt;br /&gt;
== Uploading the bundle ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve chosen a license that requires the source files to be available, you can also make a source bundle. This then includes the &amp;quot;preferred files to make edits to the work&amp;quot; and satisfies your duty to provide them. If you use&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Tutorials&amp;diff=8543</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Tutorials&amp;diff=8543"/>
		<updated>2012-08-27T08:27:02Z</updated>

		<summary type="html">&lt;p&gt;FooBar: /* Coding NewGRFs for OpenTTD and TTDPatch */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Playing OpenTTD and TTDPatch ==&lt;br /&gt;
&lt;br /&gt;
* [[PreSignalsTutorial]]: How to use pre-signals&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Coding NewGRFs for OpenTTD and TTDPatch ==&lt;br /&gt;
&lt;br /&gt;
* [[NFOTutorial|NFO Tutorial]]: How to make NewGRFs using NFO (incomplete)&lt;br /&gt;
* [[NMLTutorial|NML Tutorial]]: How to make NewGRFs using the NewGRF Meta Language (NML)&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?f=26&amp;amp;t=62069 Station Tutorial]: Complete tutorial on station coding from scratch in NFO.&lt;br /&gt;
&lt;br /&gt;
* [[Releasing a NewGRF]]: How to release your NewGRF to the public once you made one.&lt;br /&gt;
&lt;br /&gt;
== General sprite drawing ==&lt;br /&gt;
&lt;br /&gt;
* [[GraphicsTutorial]]: How to draw new 8bpp graphics sprites&lt;br /&gt;
* [[Creating_new_Sprites_with_3dsMax|Using 3dsmax]]: Creating sprites using 3DSMax (aimed at Locomotion currently)&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Tutorials&amp;diff=8513</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Tutorials&amp;diff=8513"/>
		<updated>2012-08-05T20:05:32Z</updated>

		<summary type="html">&lt;p&gt;FooBar: add link to Quast65&amp;#039;s station tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Playing OpenTTD and TTDPatch ==&lt;br /&gt;
&lt;br /&gt;
* [[PreSignalsTutorial]]: How to use pre-signals&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Coding NewGRFs for OpenTTD and TTDPatch ==&lt;br /&gt;
&lt;br /&gt;
* [[NFOTutorial|NFO Tutorial]]: How to make NewGRFs using NFO (incomplete)&lt;br /&gt;
* [[NMLTutorial|NML Tutorial]]: How to make NewGRFs using the NewGRF Meta Language (NML)&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?f=26&amp;amp;t=62069 Station Tutorial]: Complete tutorial on station coding from scratch in NFO.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== General sprite drawing ==&lt;br /&gt;
&lt;br /&gt;
* [[GraphicsTutorial]]: How to draw new 8bpp graphics sprites&lt;br /&gt;
* [[Creating_new_Sprites_with_3dsMax|Using 3dsmax]]: Creating sprites using 3DSMax (aimed at Locomotion currently)&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/32_bit_base_graphics&amp;diff=8454</id>
		<title>NMLTutorial/32 bit base graphics</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/32_bit_base_graphics&amp;diff=8454"/>
		<updated>2012-06-27T12:07:15Z</updated>

		<summary type="html">&lt;p&gt;FooBar: complete page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
In this example we&#039;ll look into a small base graphics replacement, for both 8 bit and 32 bit graphics. We&#039;ll be replacing some level crossings in temperate and actic climate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example graphics ==&lt;br /&gt;
There will be three sets of graphics: regular 8 bit sprites, 32 bit sprites for the normal zoom level and an accompanying mask file. These graphics will be replacing sprites [[:File:Ogfx1_base.png|1370 to 1373]]. The sprites for the arctic climate will occupy the same slots.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are the 8 bit sprites. Note that they&#039;re neatly ordered, so that we can use a template later on.&lt;br /&gt;
[[File:Levelcrossings8.png|frame|none|levelcrossings8.png - Level crossing sprites in open and closed state, for two climates. 8 bit.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The 32 bit sprites are very similar, but with a transparent instead of blue background. The pink bits are just to indicate the sprite borders.&lt;br /&gt;
[[File:Levelcrossings32.png|frame|none|levelcrossings32.png - Level crossing sprites in open and closed state, for two climates. 32 bit.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In order to get animation for the crossing lights with the 32 bit version, we need an additional mask file. This mask just contains the crossing lights in the exact positions as in the 32 bit file. This is an 8 bit file, so we have to use the blue background to indicate transparency.&lt;br /&gt;
[[File:Levelcrossingsmask.png|frame|none|levelcrossingsmask.png - Mask file for 32 bit sprites. 8 bit.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Replace ==&lt;br /&gt;
Let&#039;s start with the replace blocks for the 8 bit sprites. We&#039;ll add the 32 bit sprites later.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
replace replace_levelcrossings_temperate(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
    //realsprites go here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We&#039;ve chosen the identifier &amp;lt;code&amp;gt;replace_levelcrossings_temperate&amp;lt;/code&amp;gt;. It&#039;s not mandatory for 8 bit sprites alone, but we need it if we want to attach 32 bit sprites later. So why not add it straight away, right? The &amp;lt;code&amp;gt;1370&amp;lt;/code&amp;gt; is the sprite number of the first sprite we want to replace.&lt;br /&gt;
&lt;br /&gt;
=== Template ===&lt;br /&gt;
As stated before, we want to template these sprites. There are four sprites for each climate, all with the same offsets because all sprite boxes are the same size, so the template will be pretty straightforward:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
template template_levelcrossing(x, y) {&lt;br /&gt;
    //[left_x, upper_y, width, height, offset_x, offset_y]&lt;br /&gt;
    [x    , y, 64, 42, -31, -11]&lt;br /&gt;
    [x+80 , y, 64, 42, -31, -11]&lt;br /&gt;
    [x+160, y, 64, 42, -31, -11]&lt;br /&gt;
    [x+240, y, 64, 42, -31, -11]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The x and y position are variable in the template, because we have the sprites for both climates in one file. Now it&#039;s just a matter of referencing our template inside the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block and filling in the correct position of the top left pixel of the first sprite:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
replace replace_levelcrossings_temperate(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
    template_levelcrossing(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other climate ===&lt;br /&gt;
The procedure for the actic climate will be identical, but we need to select the correct sprites depending on the selected climate. This means guarding the two &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; blocks with &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements. Let&#039;s look at those &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
if (climate == CLIMATE_TEMPERATE) {&lt;br /&gt;
    //replace block for temperate to go here&lt;br /&gt;
}&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
    //replace block for temperate to go here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may use an &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; in front of the second if block, but that&#039;s not really necessary in this case. From here it&#039;s just a matter of adding the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block for the temperate climate and writing a similar one for the arctic climate. The one for the arctic climate will of course get a different identifier and different template parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
if (climate == CLIMATE_TEMPERATE) {&lt;br /&gt;
    replace replace_levelcrossings_temperate(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 0)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
    replace replace_levelcrossings_arctic(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 320)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And this is actually all there is to it, if you just want 8 bit sprites. We&#039;ll leave adding a &amp;lt;code&amp;gt;grf&amp;lt;/code&amp;gt; block and the language file over to you. It&#039;s no different than for the [[NMLTutorial/Road vehicle|road vehicle]].&lt;br /&gt;
&lt;br /&gt;
== 32 bit graphics ==&lt;br /&gt;
Adding the 32 bit sprites is as you know done through &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks. The identifiers used must be the same as for the equivalent 8 bit sprites. In our case the 32 bit sprites are for the normal zoom level, so we have to indicate &amp;lt;code&amp;gt;ZOOM_LEVEL_NORMAL&amp;lt;/code&amp;gt; and of course &amp;lt;code&amp;gt;BIT_DEPTH_32BPP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For the temperate climate &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block, we&#039;ll end up with the following &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block, simply by filling in all the information we already know:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(replace_levelcrossings_temperate, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;levelcrossings32.png&amp;quot;, &amp;quot;levelcrossingsmask.png&amp;quot;) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because the graphics files for our 32 bit sprites are ordered exactly the same as the 8 bit sprites, we can use the very same template also for the &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(replace_levelcrossings_temperate, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;levelcrossings32.png&amp;quot;, &amp;quot;levelcrossingsmask.png&amp;quot;) {&lt;br /&gt;
    template_levelcrossing(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, we can write the &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block for the arctic climate:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(replace_levelcrossings_arctic, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;levelcrossings32.png&amp;quot;, &amp;quot;levelcrossingsmask.png&amp;quot;) {&lt;br /&gt;
    template_levelcrossing(0, 320)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding to the existing code ===&lt;br /&gt;
Now, where to put these &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks, you may ask? Should you put them inside the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements, or after them? The answer is that it doesn&#039;t matter. If you like to keep things together, put them in the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; block they belong to. If you like to keep an overview of the structure of the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements, add them after it.&lt;br /&gt;
&lt;br /&gt;
Those of you used to programming, will probably prefer the first option. Those of you not used to programming, will probably prefer the latter. We&#039;re used to programming, and we want you to get used to it too, so we&#039;ll go with the first option. This will give us the following complete code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
template template_levelcrossing(x, y) {&lt;br /&gt;
    //[left_x, upper_y, width, height, offset_x, offset_y]&lt;br /&gt;
    [x    , y, 64, 42, -31, -11]&lt;br /&gt;
    [x+80 , y, 64, 42, -31, -11]&lt;br /&gt;
    [x+160, y, 64, 42, -31, -11]&lt;br /&gt;
    [x+240, y, 64, 42, -31, -11]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if (climate == CLIMATE_TEMPERATE) {&lt;br /&gt;
    replace replace_levelcrossings_temperate(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 0)&lt;br /&gt;
    }&lt;br /&gt;
    alternative_sprites(replace_levelcrossings_temperate, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;levelcrossings32.png&amp;quot;, &amp;quot;levelcrossingsmask.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 0)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
    replace replace_levelcrossings_arctic(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 320)&lt;br /&gt;
    }&lt;br /&gt;
    alternative_sprites(replace_levelcrossings_arctic, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;levelcrossings32.png&amp;quot;, &amp;quot;levelcrossingsmask.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 320)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And with that we conclude this example and in fact the whole series! Feel free to read the conclusion. Or not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Base graphics replacement|Conclusion}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/32_bit_base_graphics&amp;diff=8453</id>
		<title>NMLTutorial/32 bit base graphics</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/32_bit_base_graphics&amp;diff=8453"/>
		<updated>2012-06-27T11:44:42Z</updated>

		<summary type="html">&lt;p&gt;FooBar: intermediate save&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
In this example we&#039;ll look into a small base graphics replacement, for both 8 bit and 32 bit graphics. We&#039;ll be replacing some level crossings in temperate and actic climate.&lt;br /&gt;
&lt;br /&gt;
== Example graphics ==&lt;br /&gt;
There will be three sets of graphics: regular 8 bit sprites, 32 bit sprites for the normal zoom level and an accompanying mask file. These graphics will be replacing sprites [[:File:Ogfx1_base.png|1370 to 1373]]. The sprites for the arctic climate will occupy the same slots.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are the 8 bit sprites. Note that they&#039;re neatly ordered, so that we can use a template later on.&lt;br /&gt;
[[File:Levelcrossings8.png|frame|none|levelcrossings8.png - Level crossing sprites in open and closed state, for two climates. 8 bit.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The 32 bit sprites are very similar, but with a transparent instead of blue background. The pink bits are just to indicate the sprite borders.&lt;br /&gt;
[[File:Levelcrossings32.png|frame|none|levelcrossings32.png - Level crossing sprites in open and closed state, for two climates. 32 bit.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In order to get animation for the crossing lights with the 32 bit version, we need an additional mask file. This mask just contains the crossing lights in the exact positions as in the 32 bit file. This is an 8 bit file, so we have to use the blue background to indicate transparency.&lt;br /&gt;
[[File:Levelcrossingsmask.png|frame|none|levelcrossingsmask.png - Mask file for 32 bit sprites. 8 bit.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Replace ==&lt;br /&gt;
Let&#039;s start with the replace blocks for the 8 bit sprites. We&#039;ll add the 32 bit sprites later.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
replace replace_levelcrossings_temperate(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
    //realsprites go here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We&#039;ve chosen the identifier &amp;lt;code&amp;gt;replace_levelcrossings_temperate&amp;lt;/code&amp;gt;. It&#039;s not mandatory for 8 bit sprites alone, but we need it if we want to attach 32 bit sprites later. So why not add it straight away, right? The &amp;lt;code&amp;gt;1370&amp;lt;/code&amp;gt; is the sprite number of the first sprite we want to replace.&lt;br /&gt;
&lt;br /&gt;
=== Template ===&lt;br /&gt;
As stated before, we want to template these sprites. There are four sprites for each climate, all with the same offsets because all sprite boxes are the same size, so the template will be pretty straightforward:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
template template_levelcrossing(x, y) {&lt;br /&gt;
    //[left_x, upper_y, width, height, offset_x, offset_y]&lt;br /&gt;
    [x    , y, 64, 42, -31, -11]&lt;br /&gt;
    [x+80 , y, 64, 42, -31, -11]&lt;br /&gt;
    [x+160, y, 64, 42, -31, -11]&lt;br /&gt;
    [x+240, y, 64, 42, -31, -11]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The x and y position are variable in the template, because we have the sprites for both climates in one file. Now it&#039;s just a matter of referencing our template inside the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block and filling in the correct position of the top left pixel of the first sprite:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
replace replace_levelcrossings_temperate(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
    template_levelcrossing(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other climate ===&lt;br /&gt;
The procedure for the actic climate will be identical, but we need to select the correct sprites depending on the selected climate. This means guarding the two &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; blocks with &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements. Let&#039;s look at those &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
if (climate == CLIMATE_TEMPERATE) {&lt;br /&gt;
    replace replace_levelcrossings_temperate(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 0)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
    replace replace_levelcrossings_arctic(1370, &amp;quot;gfx/levelcrossings.png&amp;quot;) {&lt;br /&gt;
        template_levelcrossing(0, 320)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may use an &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; in front of the second if block, but that&#039;s not really necessary in this case. From here it&#039;s just a matter of adding the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block for the temperate climate and writing a similar one for the arctic climate. The one for the arctic climate will of course get a different identifier and different template parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
if (climate == CLIMATE_TEMPERATE) {&lt;br /&gt;
    //replace block for temperate to go here&lt;br /&gt;
}&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
    //replace block for temperate to go here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And this is actually all there is to it, if you just want 8 bit sprites. We&#039;ll leave adding a &amp;lt;code&amp;gt;grf&amp;lt;/code&amp;gt; block and the language file over to you. It&#039;s no different than for the [[NMLTutorial/Road vehicle|road vehicle]].&lt;br /&gt;
&lt;br /&gt;
== 32 bit graphics ==&lt;br /&gt;
&lt;br /&gt;
To define our 32 bit sprites, we have to define an &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block to go with each of the spriteset blocks. The identifiers will be the same, we&#039;ll indicate that we have normal zoom sprites via &amp;lt;code&amp;gt;ZOOM_LEVEL_NORMAL&amp;lt;/code&amp;gt; and that the sprites are 32 bit via &amp;lt;code&amp;gt;BIT_DEPTH_32BPP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also reference the new graphics files. As the 32 bit sprites and the mask sprites belong together, they go together in in the same &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block. Let&#039;s look at the first line of that block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The positions, sizes and offsets of 32 bit sprites are incidentally the same as for the 8 bit sprites. Coincidence? Of course not, this will just save us a lot of trouble, as now we can simply copy these from the 8 bit sprites. This will give us the following &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block for the first set of sprites:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is good practice to place the &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block right after the &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; block it belongs to. Let&#039;s do that and at the same time fill in the other &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And that&#039;s really all there is to defining 32 bit sprites!&lt;br /&gt;
&lt;br /&gt;
== Templates ==&lt;br /&gt;
Can we also template 32 bit graphics, I hear you ask? Well certainly, they&#039;re no different than 8 bit sprites in that respect. Let&#039;s go back to where we&#039;ve [[NMLTutorial/Road_vehicle_graphics_template|templated our example road vehicle]]. Because we were smart enough to keep the same positions, sizes and offsets for both our 8 bit and 32 bit sprites, we can simply use the same template we made earlier. This template was called &amp;lt;code&amp;gt;tmpl_truck&amp;lt;/code&amp;gt; and has template parameters for the top left position of the first of eight sprites.&lt;br /&gt;
&lt;br /&gt;
When first using this template, we simply replaced all the numbers inside the spriteset blocks with a call to the template, and ended up with this:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For our &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks we can do the same, there&#039;s really nothing to it:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the first line of the blocks remains the same, we just replace the content with the template call.&lt;br /&gt;
&lt;br /&gt;
== Other zoom levels ==&lt;br /&gt;
For each additional zoom level, you simply add additional &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks. Because of the different sprite sizes and offsets, you do have to create an additional template for each additional zoom level. If you order the sprites in a standardized way in your png files, you can keep reusing templates as we&#039;ve done before.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume we have 32 bit graphics for the 4x zoom in level. The &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; for these sprites will be similar, but you specify the different zoom level (in this case) via &amp;lt;code&amp;gt;ZOOM_LEVEL_IN_4X&amp;lt;/code&amp;gt; and reference the template you have made for sprites of this zoom level. For the first set of sprites you then get this additional &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the total set of blocks:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And with that we conclude this example and in fact the whole series! Feel free to read the conclusion. Or not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Base graphics replacement|Conclusion}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Levelcrossingsmask.png&amp;diff=8452</id>
		<title>File:Levelcrossingsmask.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Levelcrossingsmask.png&amp;diff=8452"/>
		<updated>2012-06-27T11:24:27Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Example for the NML tutorial. Graphics by Purno (level crossing lights) and Zephyris (road and terrain). Part of Dutch Rail Furniture, licensed GPLv2.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example for the NML tutorial. Graphics by Purno (level crossing lights) and Zephyris (road and terrain). Part of Dutch Rail Furniture, licensed GPLv2.&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Levelcrossings32.png&amp;diff=8451</id>
		<title>File:Levelcrossings32.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Levelcrossings32.png&amp;diff=8451"/>
		<updated>2012-06-27T11:22:57Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Example for the NML tutorial. Graphics by Purno (level crossing lights) and Zephyris (road and terrain). Part of Dutch Rail Furniture, licensed GPLv2.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example for the NML tutorial. Graphics by Purno (level crossing lights) and Zephyris (road and terrain). Part of Dutch Rail Furniture, licensed GPLv2.&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Levelcrossings8.png&amp;diff=8450</id>
		<title>File:Levelcrossings8.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Levelcrossings8.png&amp;diff=8450"/>
		<updated>2012-06-27T11:21:01Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Example for the NML tutorial. Graphics by Purno (level crossing lights) and Zephyris (road and terrain). Part of Dutch Rail Furniture, licensed GPLv2.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example for the NML tutorial. Graphics by Purno (level crossing lights) and Zephyris (road and terrain). Part of Dutch Rail Furniture, licensed GPLv2.&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8449</id>
		<title>NMLTutorial/Road vehicle 32 bit sprites</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8449"/>
		<updated>2012-06-26T20:47:32Z</updated>

		<summary type="html">&lt;p&gt;FooBar: point to base graphics replacement as next page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve seen that you can add 32 bit sprites, let&#039;s do that with an example. In fact we&#039;re going to pick up halfway down the road vehicle example from the beginning of this tutorial. We&#039;ll continue with what we had at the end of [[NMLTutorial/Road vehicle graphics|this page]].&lt;br /&gt;
&lt;br /&gt;
== Example graphics ==&lt;br /&gt;
We&#039;ll be adding 32 bit graphics for the normal zoom level, including a recolour mask. From there we&#039;ll give you some pointers on how to add sprites for other zoom levels and you can easily fill in the rest yourself. So let&#039;s look at the graphics, shall we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, let&#039;s have a look again at the 8 bit sprites we already have for our road vehicle.&lt;br /&gt;
[[Image:Flatbed truck 1 goods.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The 32 bit sprites are similar to the 8 bit sprites. The main difference is that to indicate transparancy you must use the real transparency of PNG files. If you use the blue background for transparency in 32 bit sprites, you&#039;ll get just that: a blue background. You may also use the alpha channel for semi-transparent pixels.&lt;br /&gt;
[[Image:Flatbed truck 1 goods 32.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container in 32 bit.]]&lt;br /&gt;
Note that the sprite background is actually transparent. We&#039;ve made the borders around the sprites blue, so that we can actually see where the indivual sprites are. This is not mandatory; as it doesn&#039;t end up in the game, you could have made it any other colour, even transparent if you like. We&#039;ll put this file in the &#039;&#039;gfx&#039;&#039; folder with the regular 8 bit sprites and name it &#039;&#039;flatbed_truck_1_goods_32.png‎&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now even if you use the exact colours from the palette, this won&#039;t enable company colours in 32 bit sprites. For this you have to provide an additional 8 bit mask sprite, which does use the exact palette colours. Ingame, this mask is overlayed on top of the regular 32 bit sprites, which will give you a company-coloured vehicle. Note that the mask sprites need to be in exactly the same position as the regular 32 bit sprites, as they will use the same offsets!&lt;br /&gt;
[[Image:Flatbed_truck_1_goods_mask.png|frame|none|The mask file to go with the previous 32 bit graphics]]&lt;br /&gt;
As we&#039;re now drawing in 8 bit again, we also have to use the magic blue to incidate transparent backgrounds! Also this file goes in the &#039;&#039;gfx&#039;&#039; directory and we&#039;ll name it &#039;&#039;flatbed_truck_1_goods_mask.png&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Spritesets ==&lt;br /&gt;
For the regular 8 bit sprites we have two spritesets in our NML code. Let&#039;s have a look at those again:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To define our 32 bit sprites, we have to define an &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block to go with each of the spriteset blocks. The identifiers will be the same, we&#039;ll indicate that we have normal zoom sprites via &amp;lt;code&amp;gt;ZOOM_LEVEL_NORMAL&amp;lt;/code&amp;gt; and that the sprites are 32 bit via &amp;lt;code&amp;gt;BIT_DEPTH_32BPP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also reference the new graphics files. As the 32 bit sprites and the mask sprites belong together, they go together in in the same &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block. Let&#039;s look at the first line of that block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The positions, sizes and offsets of 32 bit sprites are incidentally the same as for the 8 bit sprites. Coincidence? Of course not, this will just save us a lot of trouble, as now we can simply copy these from the 8 bit sprites. This will give us the following &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block for the first set of sprites:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is good practice to place the &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block right after the &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; block it belongs to. Let&#039;s do that and at the same time fill in the other &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And that&#039;s really all there is to defining 32 bit sprites!&lt;br /&gt;
&lt;br /&gt;
== Templates ==&lt;br /&gt;
Can we also template 32 bit graphics, I hear you ask? Well certainly, they&#039;re no different than 8 bit sprites in that respect. Let&#039;s go back to where we&#039;ve [[NMLTutorial/Road_vehicle_graphics_template|templated our example road vehicle]]. Because we were smart enough to keep the same positions, sizes and offsets for both our 8 bit and 32 bit sprites, we can simply use the same template we made earlier. This template was called &amp;lt;code&amp;gt;tmpl_truck&amp;lt;/code&amp;gt; and has template parameters for the top left position of the first of eight sprites.&lt;br /&gt;
&lt;br /&gt;
When first using this template, we simply replaced all the numbers inside the spriteset blocks with a call to the template, and ended up with this:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For our &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks we can do the same, there&#039;s really nothing to it:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the first line of the blocks remains the same, we just replace the content with the template call.&lt;br /&gt;
&lt;br /&gt;
== Other zoom levels ==&lt;br /&gt;
For each additional zoom level, you simply add additional &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks. Because of the different sprite sizes and offsets, you do have to create an additional template for each additional zoom level. If you order the sprites in a standardized way in your png files, you can keep reusing templates as we&#039;ve done before.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume we have 32 bit graphics for the 4x zoom in level. The &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; for these sprites will be similar, but you specify the different zoom level (in this case) via &amp;lt;code&amp;gt;ZOOM_LEVEL_IN_4X&amp;lt;/code&amp;gt; and reference the template you have made for sprites of this zoom level. For the first set of sprites you then get this additional &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the total set of blocks:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And with that we end this example of adding 32 bit sprites to your road vehicle NewGRF. Of course, the same method as used here also applies to providing 32 bit alternatives for any other &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; you may have. Now you can continue to learn how to replace base graphics.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|32 bit sprites|Base graphics replacement}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8448</id>
		<title>NMLTutorial/Base graphics replacement</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8448"/>
		<updated>2012-06-26T20:46:07Z</updated>

		<summary type="html">&lt;p&gt;FooBar: finish page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
A base graphics set provides the graphics you see when you have no NewGRFs loaded. If you don&#039;t want to add any new elements to the game, you can easily replace just these graphics via NewGRF.&lt;br /&gt;
&lt;br /&gt;
There are to distinct types of base graphis: those originating from TTD and those that were added later to TTDPatch and OpenTTD. The first type is replaced by means of the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block, the latter by means of the &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block. The way these blocks work are similar to the [[NMLTutorial/Spriteset and spritegroup|spriteset block]].&lt;br /&gt;
&lt;br /&gt;
== Replace TTD sprites ==&lt;br /&gt;
And by this we mean the graphics that originally were in TTD. If you use OpenGFX, this will of course replace OpenGFX sprites and not TTD sprites. But in either case we mean replacements of the sprites in trg1(r).grf (TTD) or ogfx1_base.grf (OpenGFX). It&#039;s useful to have a decode (grfcodec) of either of those grfs available to look up the sprite numbers. If you don&#039;t have that, you can find one [[:File:Ogfx1 base.png|here]] (choose to view the full resolution version below the thumbnail).&lt;br /&gt;
&lt;br /&gt;
Once you have the sprites you want to replace and know their sprite numbers, you can start writing your &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt;. The general syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
replace [&amp;lt;identifier&amp;gt;] (&amp;lt;sprite-id&amp;gt; [, &amp;lt;image-file&amp;gt;] ) {&lt;br /&gt;
	&amp;lt;list_of_realsprites&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;identifier&amp;gt;&amp;lt;/code&amp;gt; is something you choose yourself. It&#039;s useful to prefix it with &#039;&#039;replace_&#039;&#039; to avoid confusion with other identifiers in your code. It&#039;s optional if you only want to replace regular 8 bit sprites, but required if you also want to provide 32 bit sprites and/or sprites for different zoom levels. The &amp;lt;code&amp;gt;&amp;lt;sprite-id&amp;gt;&amp;lt;/code&amp;gt; is the sprite number of the first sprite you want to replace. You can then place all consecutive replacement sprites in this block. As soon as there is a gap, you start a new &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block. The &amp;lt;code&amp;gt;&amp;lt;image-file&amp;gt;&amp;lt;/code&amp;gt; is again optional. Like with a &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; you can either provide a single filename for all sprites inside the block, or omit the filename here and specify the filename for each realsprite individually.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;list_of_realsprites&amp;gt;&amp;lt;/code&amp;gt; is the same as for [[NMLTutorial/Spriteset and spritegroup|spriteset blocks]].&lt;br /&gt;
&lt;br /&gt;
=== Climates other than temperate ===&lt;br /&gt;
The previous method will provide replacement sprites for all climates at the same time. If you want to provide different sprites for each climate, you&#039;ll have to write different &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; blocks for each climate. Each of these climate specific blocks are guarded by &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements as [[NMLTutorial/Version check|introduced earlier]]. In the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statement you will test the active climate, using the &amp;lt;code&amp;gt;climate&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:General general variable]. Depending on the climate, this variable is equal to one of the following: &amp;lt;code&amp;gt;CLIMATE_TEMPERATE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CLIMATE_ARCTIC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CLIMATE_TROPICAL&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;CLIMATE_TOYLAND&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This will allow you to write something like the following:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
	replace replace_roads (1332) {&lt;br /&gt;
		template_roads(0,0,&amp;quot;gfx/roads_arctic.png&amp;quot;)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else if (climate == CLIMATE_TROPICAL) {&lt;br /&gt;
	replace replace_roads (1332) {&lt;br /&gt;
		template_roads(0,0,&amp;quot;gfx/roads_tropical.png&amp;quot;)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else if (climate == CLIMATE_TOYLAND) {&lt;br /&gt;
	replace replace_roads (1332) {&lt;br /&gt;
		template_roads(0,0,&amp;quot;gfx/roads_toyland.png&amp;quot;)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else { //in all other cases the climate will be temperate, so we need not test this&lt;br /&gt;
	replace replace_roads (1332) {&lt;br /&gt;
		template_roads(0,0,&amp;quot;gfx/roads_temperate.png&amp;quot;)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you want to replace sprites of the other trg*.grf or ogfx*.grf files, you have to do that in the same way as above. Furthermore you cannot use the sprite numbers of those files directly, but you need to look up the equivalent sprite numbers of trg1(r).grf or ogfx1_base.grf. In most cases you can easily find the equivalents just by comparing the type of sprites. There also used to be a calculator for this, but I cannot find that any more.&lt;br /&gt;
&lt;br /&gt;
== Replace OpenTTD sprites ==&lt;br /&gt;
Replacing sprites that were not originally in TTD works in a similar way, but slightly different. A &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block replaces the sprites supplied by openttd.grf. The general syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
replacenew [&amp;lt;identifier&amp;gt;] (&amp;lt;type&amp;gt; [, &amp;lt;image-file&amp;gt; [, &amp;lt;offset&amp;gt;] ] ) {&lt;br /&gt;
	&amp;lt;list_of_realsprites&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of a sprite number you now have to specify the &amp;lt;code&amp;gt;&amp;lt;type&amp;gt;&amp;lt;/code&amp;gt; type of sprites to replace. The available types can be looked up in the [http://newgrf-specs.tt-wiki.net/wiki/NML:Replace_new_sprites NML documentation]. There is a version of a decoded ogfxe_extra available [[:File:Ogfxe extra.png|here]] (choose to view the full resolution version below the thumbnail), with the types indicated.&lt;br /&gt;
&lt;br /&gt;
For some types you need to provide exactly as much sprites as indicated in the documentation. If you don&#039;t want to provide all sprites of the type, then you&#039;re allowed to do that in most cases. This is where the &amp;lt;code&amp;gt;&amp;lt;offset&amp;gt;&amp;lt;/code&amp;gt; comes in handy. Say you only want to replace the tenth and eleventh sprite of a certain type, then first of all you only provide two realsprites inside the block and second of all set the &amp;lt;code&amp;gt;&amp;lt;offset&amp;gt;&amp;lt;/code&amp;gt; to in this case 9. Counting from 0, this will replace just the tenth and eleventh sprite. If there are gaps, simply use more than one &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
Also here you may make a climate distinction via &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements, as explained above for the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block. If you want to provide the filenames via the realsprites or template (like in the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; example above) and at the same time want to use an &amp;lt;code&amp;gt;&amp;lt;offset&amp;gt;&amp;lt;/code&amp;gt;, then you have to specify &amp;lt;code&amp;gt;&amp;lt;image-file&amp;gt;&amp;lt;/code&amp;gt;. As image files specified for individual realsprites or in templates take precedence, you can in this case point to a random graphics file, as long as it exists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the next page we&#039;ll look into an example base graphics replacement, providing both 8 bit and 32 bit sprites.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Road vehicle 32 bit sprites|32 bit base graphics}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Ogfxe_extra.png&amp;diff=8447</id>
		<title>File:Ogfxe extra.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Ogfxe_extra.png&amp;diff=8447"/>
		<updated>2012-06-26T20:38:24Z</updated>

		<summary type="html">&lt;p&gt;FooBar: OpenGFX extra file. Licensed GPLv2. Source: http://dev.openttdcoop.org/projects/opengfx/repository
Added NML replacenew types.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenGFX extra file. Licensed GPLv2. Source: http://dev.openttdcoop.org/projects/opengfx/repository&lt;br /&gt;
Added NML replacenew types.&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8445</id>
		<title>NMLTutorial/Base graphics replacement</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8445"/>
		<updated>2012-06-26T16:05:58Z</updated>

		<summary type="html">&lt;p&gt;FooBar: intermediate save&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
A base graphics set provides the graphics you see when you have no NewGRFs loaded. If you don&#039;t want to add any new elements to the game, you can easily replace just these graphics via NewGRF.&lt;br /&gt;
&lt;br /&gt;
There are to distinct types of base graphis: those originating from TTD and those that were added later to TTDPatch and OpenTTD. The first type is replaced by means of the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block, the latter by means of the &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block. The way these blocks work are similar to the [[NMLTutorial/Spriteset and spritegroup|spriteset block]].&lt;br /&gt;
&lt;br /&gt;
== Replace TTD sprites ==&lt;br /&gt;
And by this we mean the graphics that originally were in TTD. If you use OpenGFX, this will of course replace OpenGFX sprites and not TTD sprites. But in either case we mean replacements of the sprites in trg1(r).grf (TTD) or ogfx1_base.grf (OpenGFX). It&#039;s useful to have a decode (grfcodec) of either of those grfs available to look up the sprite numbers. If you don&#039;t have that, you can find one [[:File:Ogfx1 base.png|here]] (choose to view the full resolution version below the thumbnail).&lt;br /&gt;
&lt;br /&gt;
Once you have the sprites you want to replace and know their sprite numbers, you can start writing your &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt;. The general syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
replace [&amp;lt;identifier&amp;gt;] (&amp;lt;sprite-id&amp;gt; [, &amp;lt;image-file&amp;gt;] ) {&lt;br /&gt;
	&amp;lt;list_of_realsprites&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;identifier&amp;gt;&amp;lt;/code&amp;gt; is something you choose yourself. It&#039;s useful to prefix it with &#039;&#039;replace_&#039;&#039; to avoid confusion with other identifiers in your code. It&#039;s optional if you only want to replace regular 8 bit sprites, but required if you also want to provide 32 bit sprites and/or sprites for different zoom levels. The &amp;lt;code&amp;gt;&amp;lt;sprite-id&amp;gt;&amp;lt;/code&amp;gt; is the sprite number of the first sprite you want to replace. You can then place all consecutive replacement sprites in this block. As soon as there is a gap, you start a new &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block. The &amp;lt;code&amp;gt;&amp;lt;image-file&amp;gt;&amp;lt;/code&amp;gt; is again optional. Like with a &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; you can either provide a single filename for all sprites inside the block, or omit the filename here and specify the filename for each realsprite individually.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;list_of_realsprites&amp;gt;&amp;lt;/code&amp;gt; is the same as for [[NMLTutorial/Spriteset and spritegroup|spriteset blocks]].&lt;br /&gt;
&lt;br /&gt;
=== Climates other than temperate ===&lt;br /&gt;
The previous method will provide replacement sprites for all climates at the same time. If you want to provide different sprites for each climate, you&#039;ll have to write different &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; blocks for each climate. Each of these climate specific blocks are guarded by &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements as [[NMLTutorial/Version check|introduced earlier]]. In the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statement you will test the active climate, using the &amp;lt;code&amp;gt;climate&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:General general variable]. Depending on the climate, this variable is equal to one of the following: &amp;lt;code&amp;gt;CLIMATE_TEMPERATE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CLIMATE_ARCTIC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CLIMATE_TROPICAL&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;CLIMATE_TOYLAND&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This will allow you to write something like the following:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_arctic.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else if (climate == CLIMATE_TROPICAL) {&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_tropical.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else if (climate == CLIMATE_TOYLAND) {&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_toyland.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else { //in all other cases the climate will be temperate, so we need not test this&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_temperate.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case you want to replace sprites of the other trg*.grf or ogfx*.grf files, you have to do that in the same way as above. Furthermore you cannot use the sprite numbers of those files directly, but you need to look up the equivalent sprite numbers of trg1(r).grf or ogfx1_base.grf. In most cases you can easily find the equivalents just by comparing the type of sprites. There also used to be a calculator for this, but I cannot find that any more.&lt;br /&gt;
&lt;br /&gt;
== Replace OpenTTD sprites ==&lt;br /&gt;
Replacing sprites that were not originally in TTD works in a similar way, but slightly different. A &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block replaces the sprites supplied by openttd.grf. The general syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
replacenew [&amp;lt;identifier&amp;gt;] (&amp;lt;type&amp;gt; [, &amp;lt;image-file&amp;gt; [, &amp;lt;offset&amp;gt;] ] ) {&lt;br /&gt;
	&amp;lt;list_of_realsprites&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of a sprite number you now have to specify the &amp;lt;code&amp;gt;&amp;lt;type&amp;gt;&amp;lt;/code&amp;gt; type of sprites to replace. The available types can be looked up in the [http://newgrf-specs.tt-wiki.net/wiki/NML:Replace_new_sprites NML documentation].&lt;br /&gt;
&lt;br /&gt;
For some types you need to provide exactly as much sprites as indicated in the documentation. If you don&#039;t want to provide all sprites of the type, then you&#039;re allowed to do that in most cases. This is where the &amp;lt;code&amp;gt;&amp;lt;offset&amp;gt;&amp;lt;/code&amp;gt; comes in handy. Say you only want to replace the tenth and eleventh sprite of a certain type, then first of all you only provide two realsprites inside the block and second of all set the &amp;lt;code&amp;gt;&amp;lt;offset&amp;gt;&amp;lt;/code&amp;gt; to in this case 9. Counting from 0, this will replace just the tenth and eleventh sprite. If there are gaps, simply use more than one &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
Also here you may make a climate distinction via &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements, as explained above for the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Road vehicle 32 bit sprites|32 bit base graphics}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8444</id>
		<title>NMLTutorial/Base graphics replacement</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8444"/>
		<updated>2012-06-26T15:48:52Z</updated>

		<summary type="html">&lt;p&gt;FooBar: intermediate save&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
A base graphics set provides the graphics you see when you have no NewGRFs loaded. If you don&#039;t want to add any new elements to the game, you can easily replace just these graphics via NewGRF.&lt;br /&gt;
&lt;br /&gt;
There are to distinct types of base graphis: those originating from TTD and those that were added later to TTDPatch and OpenTTD. The first type is replaced by means of the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block, the latter by means of the &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block. The way these blocks work are similar to the [[NMLTutorial/Spriteset and spritegroup|spriteset block]].&lt;br /&gt;
&lt;br /&gt;
== Replace TTD sprites ==&lt;br /&gt;
And by this we mean the graphics that originally were in TTD. If you use OpenGFX, this will of course replace OpenGFX sprites and not TTD sprites. But in either case we mean replacements of the sprites in trg1(r).grf (TTD) or ogfx1_base.grf. It&#039;s useful to have a decode (grfcodec) of either of those grfs available to look up the sprite numbers. If you don&#039;t have that, you can find one [[:File:Ogfx1 base.png|here]] (choose to view the full resolution version below the thumbnail).&lt;br /&gt;
&lt;br /&gt;
Once you have the sprites you want to replace and know their sprite numbers, you can start writing your &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt;. The general syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
replace [&amp;lt;identifier&amp;gt;] (&amp;lt;sprite-id&amp;gt; [, &amp;lt;image-file&amp;gt;]) {&lt;br /&gt;
	&amp;lt;list_of_realsprites&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;identifier&amp;gt;&amp;lt;/code&amp;gt; is something you choose yourself. It&#039;s useful to prefix it with &#039;&#039;replace_&#039;&#039; to avoid confusion with other identifiers in your code. It&#039;s optional if you only want to replace regular 8 bit sprites, but required if you also want to provide 32 bit sprites and/or sprites for different zoom levels. The &amp;lt;code&amp;gt;&amp;lt;sprite-id&amp;gt;&amp;lt;/code&amp;gt; is the sprite number of the first sprite you want to replace. You can then place all consecutive replacement sprites in this block. As soon as there is a gap, you start a new &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block. The &amp;lt;code&amp;gt;&amp;lt;image-file&amp;gt;&amp;lt;/code&amp;gt; is again optional. Like with a &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; you can either provide a single filename for all sprites inside the block, or omit the filename here and specify the filename for each realsprite individually.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;list_of_realsprites&amp;gt;&amp;lt;/code&amp;gt; is the same as for [[NMLTutorial/Spriteset and spritegroup|spriteset blocks]].&lt;br /&gt;
&lt;br /&gt;
=== Climates other than temperate ===&lt;br /&gt;
The previous method will provide replacement sprites for all climates at the same time. If you want to provide different sprites for each climate, you&#039;ll have to write different &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; blocks for each climate. Each of these climate specific blocks are guarded by &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statements as [[NMLTutorial/Version check|introduced earlier]]. In the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-statement you will test the active climate, using the &amp;lt;code&amp;gt;climate&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:General general variable]. Depending on the climate, this variable is equal to one of the following: &amp;lt;code&amp;gt;CLIMATE_TEMPERATE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CLIMATE_ARCTIC&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CLIMATE_TROPICAL&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;CLIMATE_TOYLAND&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This will allow you to write something like the following:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if (climate == CLIMATE_ARCTIC) {&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_arctic.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else if (climate == CLIMATE_TROPICAL) {&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_tropical.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else if (climate == CLIMATE_TOYLAND) {&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_toyland.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
else { //in all other cases the climate will be temperate, so we need not test this&lt;br /&gt;
	replace replace_roads (1332 , &amp;quot;gfx/roads_temperate.png) {&lt;br /&gt;
		template_roads(0,0)&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Replace OpenGFX sprites ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Road vehicle 32 bit sprites|32 bit base graphics}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8443</id>
		<title>NMLTutorial/Base graphics replacement</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Base_graphics_replacement&amp;diff=8443"/>
		<updated>2012-06-26T15:31:19Z</updated>

		<summary type="html">&lt;p&gt;FooBar: intermediate save&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
A base graphics set provides the graphics you see when you have no NewGRFs loaded. If you don&#039;t want to add any new elements to the game, you can easily replace just these graphics via NewGRF.&lt;br /&gt;
&lt;br /&gt;
There are to distinct types of base graphis: those originating from TTD and those that were added later to TTDPatch and OpenTTD. The first type is replaced by means of the &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block, the latter by means of the &amp;lt;code&amp;gt;replacenew&amp;lt;/code&amp;gt; block. The way these blocks work are similar to the [[NMLTutorial/Spriteset and spritegroup|spriteset block]].&lt;br /&gt;
&lt;br /&gt;
== Replace TTD sprites ==&lt;br /&gt;
And by this we mean the graphics that originally were in TTD. If you use OpenGFX, this will of course replace OpenGFX sprites and not TTD sprites. But in either case we mean replacements of the sprites in trg1(r).grf (TTD) or ogfx1_base.grf. It&#039;s useful to have a decode (grfcodec) of either of those grfs available to look up the sprite numbers. If you don&#039;t have that, you can find one [[:File:Ogfx1 base.png|here]] (choose to view the full resolution version below the thumbnail).&lt;br /&gt;
&lt;br /&gt;
Once you have the sprites you want to replace and know their sprite numbers, you can start writing your &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt;. The general syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
replace [&amp;lt;identifier&amp;gt;] (&amp;lt;sprite-id&amp;gt; [, &amp;lt;image-file&amp;gt;]) {&lt;br /&gt;
	&amp;lt;list_of_realsprites&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;identifier&amp;gt;&amp;lt;/code&amp;gt; is something you choose yourself. It&#039;s useful to prefix it with &#039;&#039;replace_&#039;&#039; to avoid confusion with other identifiers in your code. It&#039;s optional if you only want to replace regular 8 bit sprites, but required if you also want to provide 32 bit sprites and/or sprites for different zoom levels. The &amp;lt;code&amp;gt;&amp;lt;sprite-id&amp;gt;&amp;lt;/code&amp;gt; is the sprite number of the first sprite you want to replace. You can then place all consecutive replacement sprites in this block. As soon as there is a gap, you start a new &amp;lt;code&amp;gt;replace&amp;lt;/code&amp;gt; block. The &amp;lt;code&amp;gt;&amp;lt;image-file&amp;gt;&amp;lt;/code&amp;gt; is again optional. Like with a &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; you can either provide a single filename for all sprites inside the block, or omit the filename here and specify the filename for each realsprite individually.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;list_of_realsprites&amp;gt;&amp;lt;/code&amp;gt; is the same as for [[NMLTutorial/Spriteset and spritegroup|spriteset blocks]].&lt;br /&gt;
&lt;br /&gt;
=== Climates other than temperate ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Replace OpenGFX sprites ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Road vehicle 32 bit sprites|32 bit base graphics}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Ogfx1_base.png&amp;diff=8442</id>
		<title>File:Ogfx1 base.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Ogfx1_base.png&amp;diff=8442"/>
		<updated>2012-06-26T15:09:23Z</updated>

		<summary type="html">&lt;p&gt;FooBar: OpenGFX base file. Licensed GPLv2.
Source: http://dev.openttdcoop.org/projects/opengfx/repository&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenGFX base file. Licensed GPLv2.&lt;br /&gt;
Source: http://dev.openttdcoop.org/projects/opengfx/repository&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Template:NMLTutorial&amp;diff=8441</id>
		<title>Template:NMLTutorial</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Template:NMLTutorial&amp;diff=8441"/>
		<updated>2012-06-26T14:47:14Z</updated>

		<summary type="html">&lt;p&gt;FooBar: add entries for base graphics replacement&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;This is the main NML Tutorial navigation template, it is designed to be included in tutorial pages.&amp;lt;/noinclude&amp;gt;&amp;lt;div style=&amp;quot;float:right; padding-left:12px; background:none;&amp;quot;&amp;gt;&amp;lt;div style=&amp;quot;width:180px; border:1px solid #2f6fab; background:#b1cff8; padding:5px; -moz-border-radius-topleft:5px; -moz-border-radius-topright:5px; font-size: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;[[NMLTutorial|NML Tutorial]]&amp;lt;/font&amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #2f6fab; border-top-width: 0px; background:#eaf6f8; padding:5px; font-size: 8pt; line-height: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;[[NMLTutorial/Installation|Installation]]&lt;br /&gt;
;[[NMLTutorial/Graphic files|Graphics files]]&lt;br /&gt;
;[[NMLTutorial/Language files|Language files]]&lt;br /&gt;
;[[NMLTutorial/NML Syntax|NML Syntax]]&lt;br /&gt;
;[[NMLTutorial/Starting an NML file|Starting an NML file (grf block)]]&lt;br /&gt;
*[[NMLTutorial/Road vehicle|Creating a road vehicle]]&lt;br /&gt;
;[[NMLTutorial/Item|Item blocks]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle item definition|Item definition]]&lt;br /&gt;
;[[NMLTutorial/Spriteset and spritegroup|Spriteset &amp;amp; spritegroup blocks]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle graphics|Adding the graphics]]&lt;br /&gt;
;[[NMLTutorial/Template|Template blocks]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle graphics template|Templating the graphics]]&lt;br /&gt;
;[[NMLTutorial/Cargotable|Cargotable block]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle cargo graphics|Cargo-dependent graphics]]&lt;br /&gt;
;[[NMLTutorial/Callback and switch|Callbacks and switch blocks]]&lt;br /&gt;
*[[NMLTutorial/Tram|Creating a tram]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Tram articulation|Make it articulated]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Tram graphics|Adding the graphics]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Tram purchase menu|Fix the purchase menu]]&lt;br /&gt;
&lt;br /&gt;
*[[NMLTutorial/Train|Creating a train]]&lt;br /&gt;
;[[NMLTutorial/Railtypetable|Railtypetable block]]&lt;br /&gt;
**[[NMLTutorial/Train single engine|Single engine]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Train three part articulated|Three part articulated]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Train four part refit|Four part refit]]&lt;br /&gt;
;[[NMLTutorial/Parameters|GRF Parameters]]&lt;br /&gt;
**[[NMLTutorial/Train recolour|Real life recolour scheme]]&lt;br /&gt;
&lt;br /&gt;
*[[NMLTutorial/Object|Creating an object]]&lt;br /&gt;
;[[NMLTutorial/Spritelayout|Spritelayout blocks]]&lt;br /&gt;
**[[NMLTutorial/Object graphics|Adding the graphics]]&lt;br /&gt;
;[[NMLTutorial/Version check|Version checks]]&lt;br /&gt;
**[[NMLTutorial/Object slopes|Objects on slopes]]&lt;br /&gt;
;[[NMLTutorial/32 bit sprites|32 bit sprites]]&lt;br /&gt;
*[[NMLTutorial/Road vehicle 32 bit sprites|Adding 32 bit sprites]]&lt;br /&gt;
;[[NMLTutorial/Base graphics replacement|Base graphics replacement]]&lt;br /&gt;
*[[NMLTutorial/32 bit base graphics|32 bit base graphics]]&lt;br /&gt;
;[[NMLTutorial/Conclusion|Conclusion]]&lt;br /&gt;
:[[NMLTutorial/Glossary|Glossary]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #2f6fab; border-top-width: 0px; background:#eaf6f8; padding:5px; font-size: 8pt; line-height: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;[http://newgrf-specs.tt-wiki.net/wiki/NML:Main NML Documentation]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_cargo_graphics&amp;diff=8440</id>
		<title>NMLTutorial/Road vehicle cargo graphics</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_cargo_graphics&amp;diff=8440"/>
		<updated>2012-06-26T11:25:22Z</updated>

		<summary type="html">&lt;p&gt;FooBar: allow to skip ahead to 32 bit sprites section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the NML source. The code for this was originally written by Terkhen and planetmaker. The graphics used in the example are by DanMack and Zephyris. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues and concludes the [[NMLTutorial/Road vehicle graphics template|fourth part]] of the road vehicle example. We&#039;ll add some different graphics for different cargos.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== More graphics ==&lt;br /&gt;
So far, our truck is rather boring, showing just a container when it&#039;s loaded regardless of the cargo it carries. NML makes it easy to supply different graphics depending the cargo the vehicle is refitted to.&lt;br /&gt;
&lt;br /&gt;
Because the graphics are open source, I&#039;ll give them to you so you don&#039;t have to draw them first:&lt;br /&gt;
&lt;br /&gt;
[[Image:Flatbed truck 1 copper.png|frame|none|Graphics for copper cargo (not to be confused with copper ore)]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Flatbed truck 1 paper.png|frame|none|Graphics for paper cargo]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Flatbed truck 1 steel.png|frame|none|Graphics for steel cargo]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Flatbed truck 1 wood.png|frame|none|Graphics for wood cargo]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== More spritesets and spritegroups ==&lt;br /&gt;
Each block of sprites will need a spriteset and the empty and full states again need to be combined in a spriteset. Look [[NMLTutorial/Road vehicle graphics|back]] if you&#039;ve forgotten how to do that.&lt;br /&gt;
&lt;br /&gt;
The spritesets of course will use the template we made earlier. As there&#039;s nothing new to say about the spritesets and spritegroups, I&#039;ll just give them to you:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Define various cargo-specific graphics */&lt;br /&gt;
&lt;br /&gt;
/* Paper */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_paper_empty, &amp;quot;gfx/flatbed_truck_1_paper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_paper_full, &amp;quot;gfx/flatbed_truck_1_paper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_paper {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_paper_empty, spriteset_flatbed_truck_1_paper_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_paper_empty, spriteset_flatbed_truck_1_paper_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Steel */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_steel_empty, &amp;quot;gfx/flatbed_truck_1_steel.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_steel_full, &amp;quot;gfx/flatbed_truck_1_steel.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_steel {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_steel_empty, spriteset_flatbed_truck_1_steel_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_steel_empty, spriteset_flatbed_truck_1_steel_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Wood */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_wood_empty, &amp;quot;gfx/flatbed_truck_1_wood.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_wood_full, &amp;quot;gfx/flatbed_truck_1_wood.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_wood {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_wood_empty, spriteset_flatbed_truck_1_wood_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_wood_empty, spriteset_flatbed_truck_1_wood_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Copper */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_copper_empty, &amp;quot;gfx/flatbed_truck_1_copper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_copper_full, &amp;quot;gfx/flatbed_truck_1_copper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_copper {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_copper_empty, spriteset_flatbed_truck_1_copper_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_copper_empty, spriteset_flatbed_truck_1_copper_full];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These new spriteset and spritegroup definitions can be added to the one you already have.&lt;br /&gt;
&lt;br /&gt;
You may have noticed that some of the empty vehicle graphics are the same. To reduce the filesize of the NewGRF and to limit the number of sprites ingame, it is better not to duplicate sprites if you don&#039;t have to. In this case that can be solved by removing the spritesets that define duplicate sprites. From the spritegroups, you need to change the references to removed spritesets to point to the one remaining spriteset instead. Because spritesets need to be defined before they can be referenced, this will involve some reordering of the spritesets and spritegroups. Once you have the road vehicle working with different graphics, it will be a nice challenge for you to try and remove the duplicates yourself.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Cargotable ==&lt;br /&gt;
Before you can link the graphics to the vehicle and the different cargos, you need to tell NML which cargos you&#039;ll be using in your NML file. This means adding a cargotable.&lt;br /&gt;
&lt;br /&gt;
First, you need to [http://newgrf-specs.tt-wiki.net/wiki/CargoTypes#Cargo_Labels look up] the labels of the cargos we have custom graphics for. For paper, steel, copper and wood these labels are &amp;lt;code&amp;gt;PAPR&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;STEL&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;COPR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;WOOD&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
This will give us the following cargotable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
cargotable {&lt;br /&gt;
    PAPR, // Paper&lt;br /&gt;
    STEL, // Steel&lt;br /&gt;
    COPR, // Copper&lt;br /&gt;
    WOOD, // Wood&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The final comma (after WOOD) isn&#039;t needed, but doesn&#039;t hurt either. The cargotable itself should go somewhere near the top of your NML file, as it needs to be defined before you can use any of the cargo labels elsewhere. Below the template definition seems a good place for it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Linking the graphics ==&lt;br /&gt;
&lt;br /&gt;
Linking the graphics to the vehicle and a specific cargo label is easy. It is done in the graphics block of the item block of the vehicle. There you just write the label of the cargo, followed by a colon and the identifier of the spritegroup (or spriteset if you don&#039;t have a spritegroup). Finish the line with a simicolon.&lt;br /&gt;
&lt;br /&gt;
This will change our graphics block into the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
    graphics {&lt;br /&gt;
        PAPR: spritegroup_flatbed_truck_1_paper;&lt;br /&gt;
        STEL: spritegroup_flatbed_truck_1_steel;&lt;br /&gt;
        COPR: spritegroup_flatbed_truck_1_copper;&lt;br /&gt;
        WOOD: spritegroup_flatbed_truck_1_wood;&lt;br /&gt;
        default: spritegroup_flatbed_truck_1_goods; // Default to Goods.&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now this truck will show different sprites when refitted to paper, steel, copper or wood. When refitted to something else, it will show the container we already had.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The complete code ==&lt;br /&gt;
The complete NML file that defines this road vehicle with it&#039;s different (templated) graphics will now look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
//define the grf&lt;br /&gt;
grf {&lt;br /&gt;
    grfid: &amp;quot;NML\03&amp;quot;;&lt;br /&gt;
    name: string(STR_GRF_NAME);&lt;br /&gt;
    desc: string(STR_GRF_DESC);&lt;br /&gt;
    version: 0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Sprite template for a truck */&lt;br /&gt;
template tmpl_truck(x, y) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [  0 + x, y,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 16 + x, y,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 48 + x, y,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 96 + x, y,       20,    16,      -6,       -7]&lt;br /&gt;
    [128 + x, y,        8,    18,      -3,      -10]&lt;br /&gt;
    [144 + x, y,       20,    16,     -14,       -7]&lt;br /&gt;
    [176 + x, y,       28,    12,     -14,       -6]&lt;br /&gt;
    [224 + x, y,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define a cargo translation table&lt;br /&gt;
 * All cargo types that need any special treatment must be included here */&lt;br /&gt;
cargotable {&lt;br /&gt;
    PAPR, // Paper&lt;br /&gt;
    STEL, // Steel&lt;br /&gt;
    COPR, // Copper&lt;br /&gt;
    WOOD, // Wood&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define various cargo-specific graphics */&lt;br /&gt;
&lt;br /&gt;
/* Paper */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_paper_empty, &amp;quot;gfx/flatbed_truck_1_paper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_paper_full, &amp;quot;gfx/flatbed_truck_1_paper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_paper {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_paper_empty, spriteset_flatbed_truck_1_paper_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_paper_empty, spriteset_flatbed_truck_1_paper_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Steel */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_steel_empty, &amp;quot;gfx/flatbed_truck_1_steel.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_steel_full, &amp;quot;gfx/flatbed_truck_1_steel.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_steel {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_steel_empty, spriteset_flatbed_truck_1_steel_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_steel_empty, spriteset_flatbed_truck_1_steel_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Wood */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_wood_empty, &amp;quot;gfx/flatbed_truck_1_wood.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_wood_full, &amp;quot;gfx/flatbed_truck_1_wood.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_wood {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_wood_empty, spriteset_flatbed_truck_1_wood_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_wood_empty, spriteset_flatbed_truck_1_wood_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Copper */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_copper_empty, &amp;quot;gfx/flatbed_truck_1_copper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(0, 0) &lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_copper_full, &amp;quot;gfx/flatbed_truck_1_copper.png&amp;quot;) { &lt;br /&gt;
    tmpl_truck(260, 0) &lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_copper {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_copper_empty, spriteset_flatbed_truck_1_copper_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_copper_empty, spriteset_flatbed_truck_1_copper_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Goods */&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
spritegroup spritegroup_flatbed_truck_1_goods {&lt;br /&gt;
    loaded: [spriteset_flatbed_truck_1_goods_empty, spriteset_flatbed_truck_1_goods_full];&lt;br /&gt;
    loading: [spriteset_flatbed_truck_1_goods_empty, spriteset_flatbed_truck_1_goods_full];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the road vehicle */&lt;br /&gt;
item(FEAT_ROADVEHS, item_flatbed_truck_1) {&lt;br /&gt;
    property {&lt;br /&gt;
        /* Properties common to all vehicle types */&lt;br /&gt;
        name:                           string(STR_NAME_FLATBED_TRUCK_1);&lt;br /&gt;
        climates_available:             bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);&lt;br /&gt;
        introduction_date:              date(1926,01,01);&lt;br /&gt;
        model_life:                     65;&lt;br /&gt;
        /* retire_early not set, use default retirement behaviour */&lt;br /&gt;
        vehicle_life:                   15;&lt;br /&gt;
        reliability_decay:              20;&lt;br /&gt;
        refittable_cargo_classes:       bitmask(CC_PIECE_GOODS, CC_EXPRESS);&lt;br /&gt;
        non_refittable_cargo_classes:   bitmask(CC_PASSENGERS, CC_REFRIGERATED);&lt;br /&gt;
        loading_speed:                  5;&lt;br /&gt;
        cost_factor:                    108;&lt;br /&gt;
        running_cost_factor:            90;&lt;br /&gt;
        /* cargo_age_period is left at default */&lt;br /&gt;
&lt;br /&gt;
        /* RV-specific properties */&lt;br /&gt;
        sprite_id:                      SPRITE_ID_NEW_ROADVEH; //enable new graphics&lt;br /&gt;
        speed:                          48 km/h;&lt;br /&gt;
        misc_flags:                     bitmask(ROADVEH_FLAG_2CC);&lt;br /&gt;
        refit_cost:                     0; // Refitting is free&lt;br /&gt;
        /* callback_flags are not set, no need to manually enable callbacks */&lt;br /&gt;
        running_cost_base:              RUNNING_COST_ROADVEH;&lt;br /&gt;
        power:                          120 hp;&lt;br /&gt;
        weight:                         9.5 ton;&lt;br /&gt;
        /* TE and air drag coefficient is left at default */&lt;br /&gt;
        cargo_capacity:                 20;&lt;br /&gt;
        sound_effect:                   SOUND_BUS_START_PULL_AWAY;&lt;br /&gt;
        /* Visual effect is left at default (no effect) */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /* Define graphics */&lt;br /&gt;
    graphics {&lt;br /&gt;
        PAPR: spritegroup_flatbed_truck_1_paper;&lt;br /&gt;
        STEL: spritegroup_flatbed_truck_1_steel;&lt;br /&gt;
        COPR: spritegroup_flatbed_truck_1_copper;&lt;br /&gt;
        WOOD: spritegroup_flatbed_truck_1_wood;&lt;br /&gt;
        default: spritegroup_flatbed_truck_1_goods; // Default to a goods container.&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This concludes our road vehicle example. If you think this was easy or not too bad, with some more practice, you&#039;ll make a great NML coder. If you think this was really difficult, you&#039;d better give up now that you haven&#039;t spent too much time; maybe you should concentrate on graphics and leave the code to others.&lt;br /&gt;
&lt;br /&gt;
For the ones brave enough to continue, we have some really nice topics in store for you. You&#039;ll learn to do some funky stuff with callbacks and switches (amonst others) and we have three more fully featured examples for you, each a little more advanced than the previous.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t care about all the other fancy things you can do, but do want to add 32 bit sprites, for this time we&#039;ll allow you to skip ahead to the [[NMLTutorial/32 bit sprites|part on 32 bit sprites]]. Adding 32 bit sprites does not require any more knowledge than what you have gained now.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Cargotable|Callback and switch}}&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align:center&amp;quot;&amp;gt;or&amp;lt;/div&amp;gt;&lt;br /&gt;
{{NMLTutorialNavbar|Cargotable|32 bit sprites}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Object_slopes&amp;diff=8439</id>
		<title>NMLTutorial/Object slopes</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Object_slopes&amp;diff=8439"/>
		<updated>2012-06-26T11:20:58Z</updated>

		<summary type="html">&lt;p&gt;FooBar: next part is now 32 bit sprites&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the [http://dev.openttdcoop.org/projects/dutchroadfurniture/repository Dutch Road Furniture]. The original graphics for this are by FooBar. The code is by FooBar, based on code for the object example from the [http://dev.openttdcoop.org/projects/nml/repository/show/examples NML source] by planetmaker and Hirundo. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues and concludes the [[NMLTutorial/Object graphics|second part]] of the object example. In this last part we&#039;ll make the object compatible with sloped terrain as well as snow and desert terrain. For this some recent features of OpenTTD will be used, which makes this last part of the example &#039;&#039;&#039;incompatible with anything other than OpenTTD 1.2.0 (r22723) or higher&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Version check ==&lt;br /&gt;
As indicated, the particular code on this page only works on OpenTTD 1.2.0 (r22723) or higher. Therefore, we want to disable this NewGRF on older versions. This is done by comparing said version number with the &amp;lt;code&amp;gt;openttd_version&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:General#General_variables variable] in an &#039;&#039;if statement&#039;&#039;. To avoid having to write the version number in hex, we can use the &amp;lt;code&amp;gt;version_openttd()&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Builtin_functions function] and have NML do that for us. If the current game version is older than said version number generate a fatal [http://newgrf-specs.tt-wiki.net/wiki/NML:Error error] message, otherwise skip the error message and continue with the rest of the NewGRF:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
if (version_openttd(1,2,0,22723) &amp;gt; openttd_version) {&lt;br /&gt;
	error(FATAL, REQUIRES_OPENTTD, string(STR_OPENTTD_VERSION));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the error message we set that it must be &amp;lt;code&amp;gt;FATAL&amp;lt;/code&amp;gt;, which means that an error message is issued and loading the NewGRF is aborted. As message we use the builtin string &amp;lt;code&amp;gt;REQUIRES_OPENTTD&amp;lt;/code&amp;gt; (automatically translated by the game). This default string must be supplied with the actual version number, provided via the custom string &amp;lt;code&amp;gt;string(STR_OPENTTD_VERSION)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Due to this custom string reference, we of course also must define it in the language file (it&#039;s sufficient to only have this in the default language file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
STR_OPENTTD_VERSION :1.2.0 (r22723)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sloped ground sprites ==&lt;br /&gt;
So far our object can only show flat ground tiles. Now we could make a spritelayout for each different slope (19) and each different view of the object (4) which would give us 76 spritelayouts. Luckily, recent versions of OpenTTD allow us to use temporary variable storage to be used inside spritelayouts, which means we can write a small piece of NML code that makes the game calculate what ground sprite to use for a given slope.&lt;br /&gt;
&lt;br /&gt;
This calculation is done in a switch block, so we need to reference a different switch block from the graphics block. This new switch block in turn will reference the switch block we already have:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
        default:            switch_fingerpost_3_object;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The new switch block will make the calculation based on the &amp;lt;code&amp;gt;tile_slope&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Objects#Object_variables object variable] using the &amp;lt;code&amp;gt;slope_to_sprite_offset()&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Builtin_functions function]. This calculates how many sprites (the offset) after the flat ground sprite the sprite for the slope is located at. This is then stored in temporary storage register 0 using the &amp;lt;code&amp;gt;STORE_TEMP()&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Builtin_functions function].&lt;br /&gt;
&lt;br /&gt;
Because we don&#039;t actually need to make a decision in this switch (it&#039;s just used to store the slope sprite offset), we only have a default value inside this switch referencing the original switch block that selected the proper spritelayout block depending on the object view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
switch (FEAT_OBJECTS, SELF, switch_fingerpost_3_object, STORE_TEMP(slope_to_sprite_offset(tile_slope), 0)) {&lt;br /&gt;
	switch_fingerpost_3_view;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that we have the calculation, we must actually use it in the four spritelayout blocks for the ground sprite. This means that instead of only referencing the flat ground sprite, we must add the calculated slope sprite offset to this to actually get the sprite number for the slope we want:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
//south east&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_SE {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: GROUNDSPRITE_NORMAL + LOAD_TEMP(0);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(0);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 6; //from NE edge&lt;br /&gt;
        yoffset: 12; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we take the sprite number of the flat ground sprite (&amp;lt;code&amp;gt;GROUNDSPRITE_NORMAL&amp;lt;/code&amp;gt;) and add the calculated offset to this. We get this offset from the temporary storage using the &amp;lt;code&amp;gt;LOAD_TEMP()&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Builtin_functions function]. The argument &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; defines what storage register we want to get a value from. Because we stored in 0, we need to load from 0 as well.&lt;br /&gt;
&lt;br /&gt;
The ground sprite for the other spritelayouts is changed in the same way. We will not give you the other spritelayout blocks here, as they need to be changed once more.&lt;br /&gt;
&lt;br /&gt;
=== Purchase menu ===&lt;br /&gt;
Now we have a small problem with the purchase menu. The &amp;lt;code&amp;gt;tile_slope&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Objects#Object_variables object variable] isn&#039;t available there, so we cannot use the calculation for the purchase menu! This can be solved easily by not doing the calculation for the purchase menu and always have a sprite offset of 0 there (always giving the flat ground sprite). So for the purchase menu we just set the temporary storage value to 0.&lt;br /&gt;
&lt;br /&gt;
First reference the purchase callback from the graphics block and link to a switch block where we will set the temporary storage:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
        purchase:           switch_fingerpost_3_purchase;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself will only set temporary storage register 0 to a value of 0 and then immediately reference the switch block that makes the decision based on the object views:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
switch (FEAT_OBJECTS, SELF, switch_fingerpost_3_purchase, STORE_TEMP(0, 0)) {&lt;br /&gt;
	switch_fingerpost_3_view;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the purchase menu works again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Snow and desert tiles ==&lt;br /&gt;
Now our object works fine on slopes, but still shows a grass tile on snow and desert tiles. Not good! This is because we always use &amp;lt;code&amp;gt;GROUNDSPRITE_NORMAL&amp;lt;/code&amp;gt; as a base for the ground sprite to draw, which is the grass tile in all climates.&lt;br /&gt;
&lt;br /&gt;
The solution here is to use the &amp;lt;code&amp;gt;terrain_type&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Objects#Object_variables object variable] to check what terrain we&#039;re actually building on. Now you can again have a bunch of spritelayouts for each different terrain type, but also here we can use the temporary storage to save what terrain sprite to use and retrieve this again in the spritelayouts. Let&#039;s give that a go, shall we?&lt;br /&gt;
* For this we will use the second storage register (with index 1).&lt;br /&gt;
* The default case is the normal grounds sprite, so store that in the register: &amp;lt;code&amp;gt;STORE_TEMP(GROUNDSPRITE_NORMAL, 1)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* In case of the tropic climate, we need to choose between grass and desert depending on the &amp;lt;code&amp;gt;terrain_type&amp;lt;/code&amp;gt; variable. If grass, use the storage we already had, otherwise change the storage: &amp;lt;code&amp;gt;STORE_TEMP(terrain_type == TILETYPE_DESERT ? GROUNDSPRITE_DESERT : LOAD_TEMP(1), 1)&amp;lt;/code&amp;gt;. What this does is store in register 1: if the terrain is desert the sprite number of the desert flat ground sprite from &amp;lt;code&amp;gt;GROUNDSPRITE_DESERT&amp;lt;/code&amp;gt; and if the terrain is not desert what we already had in register 1.&lt;br /&gt;
* In case of the arctic climate, we need to choose between grass and snow depending on the &amp;lt;code&amp;gt;terrain_type&amp;lt;/code&amp;gt; variable. If grass, use the storage we already had, otherwise change the storage: &amp;lt;code&amp;gt;STORE_TEMP(terrain_type == TILETYPE_SNOW   ? GROUNDSPRITE_SNOW   : LOAD_TEMP(1), 1)&amp;lt;/code&amp;gt;. What this does is store in register 1: if the terrain is snow the sprite number of the snow flat ground sprite from &amp;lt;code&amp;gt;GROUNDSPRITE_SNOW&amp;lt;/code&amp;gt; and if the terrain is not snow what we already had in register 1.&lt;br /&gt;
&lt;br /&gt;
These three expressions need to be put somewhere in our NML file. Each expression can go in a separate switch block all linked together, but luckily we may provide an array of expressions in a single switch block. This is done by separating each command by a comma and grouping them together between straight brackets. The decision of the switch block is based on the last expression in the chain (but that is in this case not important as we only have a default return for the switch block).&lt;br /&gt;
&lt;br /&gt;
Change the switch block we made earlier on this page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
switch (FEAT_OBJECTS, SELF, switch_fingerpost_3_object, [&lt;br /&gt;
        //tile slope offset in storage register 0&lt;br /&gt;
        STORE_TEMP(slope_to_sprite_offset(tile_slope), 0),&lt;br /&gt;
        //terrain type in storage register 1&lt;br /&gt;
        STORE_TEMP(GROUNDSPRITE_NORMAL, 1),&lt;br /&gt;
        STORE_TEMP(terrain_type == TILETYPE_DESERT ? GROUNDSPRITE_DESERT : LOAD_TEMP(1), 1),&lt;br /&gt;
        STORE_TEMP(terrain_type == TILETYPE_SNOW   ? GROUNDSPRITE_SNOW   : LOAD_TEMP(1), 1)&lt;br /&gt;
        ]) {&lt;br /&gt;
    switch_fingerpost_3_view;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For this new calculation to work, we must also change the spritelayout blocks. The choice of the flat ground sprite number is now stored in temporary storage register 1, so we must use this instead of the hardcoded &amp;lt;code&amp;gt;GROUNDSPRITE_NORMAL&amp;lt;/code&amp;gt;. Just replace &amp;lt;code&amp;gt;GROUNDSPRITE_NORMAL&amp;lt;/code&amp;gt; for the ground sprite with &amp;lt;code&amp;gt;LOAD_TEMP(1)&amp;lt;/code&amp;gt; in all spritelayout blocks. If you haven&#039;t made the first change to all four spritelayout blocks, do that now all in one go:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
//south east&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_SE {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(0);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 6; //from NE edge&lt;br /&gt;
        yoffset: 12; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//south west&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_SW {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(1);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 12; //from NE edge&lt;br /&gt;
        yoffset: 6; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//north west&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_NW {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(2);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 6; //from NE edge&lt;br /&gt;
        yoffset: 0; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//north east&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_NE {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(3);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 0; //from NE edge&lt;br /&gt;
        yoffset: 6; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Purchase menu ===&lt;br /&gt;
Now we have again broken the purchase menu, because the &amp;lt;code&amp;gt;terrain_type&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Objects#Object_variables object variable] is also not available there. This can be solved easily by again not doing the calculation for the purchase menu and always have the grass terrain sprite in the purchase menu. So for the purchase menu we just set the temporary storage register 1 value to &amp;lt;code&amp;gt;GROUNDSPRITE_NORMAL&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This change is similar to the change of the other switch block we just did:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
switch (FEAT_OBJECTS, SELF, switch_fingerpost_3_purchase, [&lt;br /&gt;
        //use flat gound sprite for purchase menu&lt;br /&gt;
        STORE_TEMP(0, 0),&lt;br /&gt;
        //use normal terrain for purchase menu&lt;br /&gt;
        STORE_TEMP(GROUNDSPRITE_NORMAL, 1),&lt;br /&gt;
        ]) {&lt;br /&gt;
	switch_fingerpost_3_view;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So for the purchase menu we just use the flat sprite of the grass terrain. Now the purchase menu works again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With this the end of the object example is reached. You can now encode this as a NewGRF.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The complete code ==&lt;br /&gt;
If you put everything in the correct order, this will be the complete NML file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example small&amp;quot;&amp;gt;&lt;br /&gt;
// define the newgrf&lt;br /&gt;
grf {&lt;br /&gt;
    grfid:                  &amp;quot;\FB\FB\05\01&amp;quot;;&lt;br /&gt;
    name:                   string(STR_GRF_NAME);&lt;br /&gt;
    desc:                   string(STR_GRF_DESCRIPTION);&lt;br /&gt;
    version:                0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//check OpenTTD version&lt;br /&gt;
//parameterized spritelayout is only supported since OpenTTD 1.2.0 r22723&lt;br /&gt;
if (version_openttd(1,2,0,22723) &amp;gt; openttd_version) {&lt;br /&gt;
	error(FATAL, REQUIRES_OPENTTD, string(STR_OPENTTD_VERSION));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//templates&lt;br /&gt;
template template_fingerpost(x,y,filename) {&lt;br /&gt;
    [x,     y,      20,     32,     -10,    -28,    filename]&lt;br /&gt;
    [x+30,  y,      20,     32,     -10,    -28,    filename]&lt;br /&gt;
    [x+60,  y,      20,     32,     -10,    -28,    filename]&lt;br /&gt;
    [x+90,  y,      20,     32,     -10,    -28,    filename]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//spriteset with four directions&lt;br /&gt;
spriteset (spriteset_fingerpost_3) {&lt;br /&gt;
    template_fingerpost(0,0,&amp;quot;gfx/dutch_fingerpost.png&amp;quot;)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* spritelayouts */&lt;br /&gt;
&lt;br /&gt;
//south east&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_SE {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(0);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 6; //from NE edge&lt;br /&gt;
        yoffset: 12; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//south west&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_SW {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(1);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 12; //from NE edge&lt;br /&gt;
        yoffset: 6; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//north west&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_NW {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(2);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 6; //from NE edge&lt;br /&gt;
        yoffset: 0; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//north east&lt;br /&gt;
spritelayout spritelayout_fingerpost_3_NE {&lt;br /&gt;
    ground {&lt;br /&gt;
        sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
    }&lt;br /&gt;
    building {&lt;br /&gt;
        sprite: spriteset_fingerpost_3(3);&lt;br /&gt;
        xextent: 4;&lt;br /&gt;
        yextent: 4;&lt;br /&gt;
        zextent: 24;&lt;br /&gt;
        xoffset: 0; //from NE edge&lt;br /&gt;
        yoffset: 6; //from NW edge&lt;br /&gt;
        zoffset: 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//decide spritelayout for each of the 4 views&lt;br /&gt;
switch (FEAT_OBJECTS, SELF, switch_fingerpost_3_view, view) {&lt;br /&gt;
    1:  spritelayout_fingerpost_3_SW;&lt;br /&gt;
    2:  spritelayout_fingerpost_3_NW;&lt;br /&gt;
    3:  spritelayout_fingerpost_3_NE;&lt;br /&gt;
    spritelayout_fingerpost_3_SE;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//calculate ground sprite for object&lt;br /&gt;
switch (FEAT_OBJECTS, SELF, switch_fingerpost_3_object, [&lt;br /&gt;
        //tile slope offset in storage register 0&lt;br /&gt;
        STORE_TEMP(slope_to_sprite_offset(tile_slope), 0),&lt;br /&gt;
        //terrain type in storage register 1&lt;br /&gt;
        STORE_TEMP(GROUNDSPRITE_NORMAL, 1),&lt;br /&gt;
        STORE_TEMP(terrain_type == TILETYPE_DESERT ? GROUNDSPRITE_DESERT : LOAD_TEMP(1), 1),&lt;br /&gt;
        STORE_TEMP(terrain_type == TILETYPE_SNOW   ? GROUNDSPRITE_SNOW   : LOAD_TEMP(1), 1)&lt;br /&gt;
        ]) {&lt;br /&gt;
    switch_fingerpost_3_view;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//calculate ground sprite for purchase menu&lt;br /&gt;
switch (FEAT_OBJECTS, SELF, switch_fingerpost_3_purchase, [&lt;br /&gt;
        //use flat gound sprite for purchase menu&lt;br /&gt;
        STORE_TEMP(0, 0),&lt;br /&gt;
        //use normal terrain for purchase menu&lt;br /&gt;
        STORE_TEMP(GROUNDSPRITE_NORMAL, 1),&lt;br /&gt;
        ]) {&lt;br /&gt;
    switch_fingerpost_3_view;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
item (FEAT_OBJECTS, item_fingerpost_3) {&lt;br /&gt;
    property {&lt;br /&gt;
        class:                  &amp;quot;NLRF&amp;quot;;&lt;br /&gt;
        classname:              string(STR_NLRF);&lt;br /&gt;
        name:                   string(STR_FINGERPOST_3);&lt;br /&gt;
        climates_available:     ALL_CLIMATES;&lt;br /&gt;
        size:                   [1,1];&lt;br /&gt;
        build_cost_multiplier:  2;&lt;br /&gt;
        remove_cost_multiplier: 8;&lt;br /&gt;
        introduction_date:      date(1961,1,1);&lt;br /&gt;
        end_of_life_date:       0xFFFFFFFF;&lt;br /&gt;
        object_flags:           bitmask(OBJ_FLAG_REMOVE_IS_INCOME, OBJ_FLAG_NO_FOUNDATIONS, OBJ_FLAG_ALLOW_BRIDGE);&lt;br /&gt;
        height:                 2;&lt;br /&gt;
        num_views:              4;&lt;br /&gt;
    }&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:            switch_fingerpost_3_object;&lt;br /&gt;
        purchase:           switch_fingerpost_3_purchase;&lt;br /&gt;
        autoslope:          return(CB_RESULT_AUTOSLOPE);&lt;br /&gt;
        additional_text:    string(STR_FINGERPOST_3_PURCHASE);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The language file will now contain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example small&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
&lt;br /&gt;
#Main grf title and description&lt;br /&gt;
STR_GRF_NAME        :{TITLE}&lt;br /&gt;
STR_GRF_DESCRIPTION :Description: {SILVER}Dutch Road Furniture is an eyecandy object NewGRF that features road furniture that can be found alongside Dutch roads. {}(c)2011 FooBar. {}{BLACK}License: {SILVER}GPLv2 or higher.&lt;br /&gt;
&lt;br /&gt;
#error messages&lt;br /&gt;
STR_OPENTTD_VERSION :1.2.0 (r22723)&lt;br /&gt;
&lt;br /&gt;
#object classes&lt;br /&gt;
STR_NLRF            :Dutch Road Furniture&lt;br /&gt;
&lt;br /&gt;
#object name and description&lt;br /&gt;
STR_FINGERPOST_3            :Dutch Fingerpost three-way&lt;br /&gt;
STR_FINGERPOST_3_PURCHASE   :The three-way fingerpost is centered at one side of the tile and facing outward. Intended to be placed directly opposite of the secondary road at a three-way junction.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next part of the tutorial will teach you some things about adding 32 bit sprites to your NewGRFs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Version check|32 bit sprites}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8438</id>
		<title>NMLTutorial/Road vehicle 32 bit sprites</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8438"/>
		<updated>2012-06-26T11:19:56Z</updated>

		<summary type="html">&lt;p&gt;FooBar: finish page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve seen that you can add 32 bit sprites, let&#039;s do that with an example. In fact we&#039;re going to pick up halfway down the road vehicle example from the beginning of this tutorial. We&#039;ll continue with what we had at the end of [[NMLTutorial/Road vehicle graphics|this page]].&lt;br /&gt;
&lt;br /&gt;
== Example graphics ==&lt;br /&gt;
We&#039;ll be adding 32 bit graphics for the normal zoom level, including a recolour mask. From there we&#039;ll give you some pointers on how to add sprites for other zoom levels and you can easily fill in the rest yourself. So let&#039;s look at the graphics, shall we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, let&#039;s have a look again at the 8 bit sprites we already have for our road vehicle.&lt;br /&gt;
[[Image:Flatbed truck 1 goods.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The 32 bit sprites are similar to the 8 bit sprites. The main difference is that to indicate transparancy you must use the real transparency of PNG files. If you use the blue background for transparency in 32 bit sprites, you&#039;ll get just that: a blue background. You may also use the alpha channel for semi-transparent pixels.&lt;br /&gt;
[[Image:Flatbed truck 1 goods 32.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container in 32 bit.]]&lt;br /&gt;
Note that the sprite background is actually transparent. We&#039;ve made the borders around the sprites blue, so that we can actually see where the indivual sprites are. This is not mandatory; as it doesn&#039;t end up in the game, you could have made it any other colour, even transparent if you like. We&#039;ll put this file in the &#039;&#039;gfx&#039;&#039; folder with the regular 8 bit sprites and name it &#039;&#039;flatbed_truck_1_goods_32.png‎&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now even if you use the exact colours from the palette, this won&#039;t enable company colours in 32 bit sprites. For this you have to provide an additional 8 bit mask sprite, which does use the exact palette colours. Ingame, this mask is overlayed on top of the regular 32 bit sprites, which will give you a company-coloured vehicle. Note that the mask sprites need to be in exactly the same position as the regular 32 bit sprites, as they will use the same offsets!&lt;br /&gt;
[[Image:Flatbed_truck_1_goods_mask.png|frame|none|The mask file to go with the previous 32 bit graphics]]&lt;br /&gt;
As we&#039;re now drawing in 8 bit again, we also have to use the magic blue to incidate transparent backgrounds! Also this file goes in the &#039;&#039;gfx&#039;&#039; directory and we&#039;ll name it &#039;&#039;flatbed_truck_1_goods_mask.png&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Spritesets ==&lt;br /&gt;
For the regular 8 bit sprites we have two spritesets in our NML code. Let&#039;s have a look at those again:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To define our 32 bit sprites, we have to define an &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block to go with each of the spriteset blocks. The identifiers will be the same, we&#039;ll indicate that we have normal zoom sprites via &amp;lt;code&amp;gt;ZOOM_LEVEL_NORMAL&amp;lt;/code&amp;gt; and that the sprites are 32 bit via &amp;lt;code&amp;gt;BIT_DEPTH_32BPP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also reference the new graphics files. As the 32 bit sprites and the mask sprites belong together, they go together in in the same &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block. Let&#039;s look at the first line of that block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The positions, sizes and offsets of 32 bit sprites are incidentally the same as for the 8 bit sprites. Coincidence? Of course not, this will just save us a lot of trouble, as now we can simply copy these from the 8 bit sprites. This will give us the following &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block for the first set of sprites:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is good practice to place the &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block right after the &amp;lt;code&amp;gt;spriteset&amp;lt;code&amp;gt; block it belongs to. Let&#039;s do that and at the same time fill in the other &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And that&#039;s really all there is to defining 32 bit sprites!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Templates ==&lt;br /&gt;
Can we also template 32 bit graphics, I hear you ask? Well certainly, they&#039;re no different than 8 bit sprites in that respect. Let&#039;s go back to where we&#039;ve [[NMLTutorial/Road_vehicle_graphics_template|templated our example road vehicle]]. Because we were smart enough to keep the same positions, sizes and offsets for both our 8 bit and 32 bit sprites, we can simply use the same template we made earlier. This template was called &amp;lt;code&amp;gt;tmpl_truck&amp;lt;/code&amp;gt; and has template parameters for the top left position of the first of eight sprites.&lt;br /&gt;
&lt;br /&gt;
When first using this template, we simply replaced all the numbers inside the spriteset blocks with a call to the template, and ended up with this:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For our &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks we can do the same, there&#039;s really nothing to it:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the first line of the blocks remains the same, we just replace the content with the template call.&lt;br /&gt;
&lt;br /&gt;
== Other zoom levels ==&lt;br /&gt;
For each additional zoom level, you simply add additional &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks. Because of the different sprite sizes and offsets, you do have to create an additional template for each additional zoom level. If you order the sprites in a standardized way in your png files, you can keep reusing templates as we&#039;ve done before.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume we have 32 bit graphics for the 4x zoom in level. The &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; for these sprites will be similar, but you specify the different zoom level (in this case) via &amp;lt;code&amp;gt;ZOOM_LEVEL_IN_4X&amp;lt;/code&amp;gt; and reference the template you have made for sprites of this zoom level. For the first set of sprites you then get this additional &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the total set of blocks:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck_zi4(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And with that we end this example of adding 32 bit sprites to your road vehicle NewGRF. Of course, the same method as used here also applies to providing 32 bit alternatives for any other &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; you may have. Only thing left for you to skip is a useless conclusion :) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|32 bit sprites|Conclusion}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8437</id>
		<title>NMLTutorial/Road vehicle 32 bit sprites</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8437"/>
		<updated>2012-06-26T11:08:38Z</updated>

		<summary type="html">&lt;p&gt;FooBar: intermediate save&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve seen that you can add 32 bit sprites, let&#039;s do that with an example. In fact we&#039;re going to pick up halfway down the road vehicle example from the beginning of this tutorial. We&#039;ll continue with what we had at the end of [[NMLTutorial/Road vehicle graphics|this page]].&lt;br /&gt;
&lt;br /&gt;
== Example graphics ==&lt;br /&gt;
We&#039;ll be adding 32 bit graphics for the normal zoom level, including a recolour mask. From there we&#039;ll give you some pointers on how to add sprites for other zoom levels and you can easily fill in the rest yourself. So let&#039;s look at the graphics, shall we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, let&#039;s have a look again at the 8 bit sprites we already have for our road vehicle.&lt;br /&gt;
[[Image:Flatbed truck 1 goods.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The 32 bit sprites are similar to the 8 bit sprites. The main difference is that to indicate transparancy you must use the real transparency of PNG files. If you use the blue background for transparency in 32 bit sprites, you&#039;ll get just that: a blue background. You may also use the alpha channel for semi-transparent pixels.&lt;br /&gt;
[[Image:Flatbed truck 1 goods 32.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container in 32 bit.]]&lt;br /&gt;
Note that the sprite background is actually transparent. We&#039;ve made the borders around the sprites blue, so that we can actually see where the indivual sprites are. This is not mandatory; as it doesn&#039;t end up in the game, you could have made it any other colour, even transparent if you like. We&#039;ll put this file in the &#039;&#039;gfx&#039;&#039; folder with the regular 8 bit sprites and name it &#039;&#039;flatbed_truck_1_goods_32.png‎&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now even if you use the exact colours from the palette, this won&#039;t enable company colours in 32 bit sprites. For this you have to provide an additional 8 bit mask sprite, which does use the exact palette colours. Ingame, this mask is overlayed on top of the regular 32 bit sprites, which will give you a company-coloured vehicle. Note that the mask sprites need to be in exactly the same position as the regular 32 bit sprites, as they will use the same offsets!&lt;br /&gt;
[[Image:Flatbed_truck_1_goods_mask.png|frame|none|The mask file to go with the previous 32 bit graphics]]&lt;br /&gt;
As we&#039;re now drawing in 8 bit again, we also have to use the magic blue to incidate transparent backgrounds! Also this file goes in the &#039;&#039;gfx&#039;&#039; directory and we&#039;ll name it &#039;&#039;flatbed_truck_1_goods_mask.png&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Spritesets ==&lt;br /&gt;
For the regular 8 bit sprites we have two spritesets in our NML code. Let&#039;s have a look at those again:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To define our 32 bit sprites, we have to define an &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block to go with each of the spriteset blocks. The identifiers will be the same, we&#039;ll indicate that we have normal zoom sprites via &amp;lt;code&amp;gt;ZOOM_LEVEL_NORMAL&amp;lt;/code&amp;gt; and that the sprites are 32 bit via &amp;lt;code&amp;gt;BIT_DEPTH_32BPP&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also reference the new graphics files. As the 32 bit sprites and the mask sprites belong together, they go together in in the same &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block. Let&#039;s look at the first line of that block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The positions, sizes and offsets of 32 bit sprites are incidentally the same as for the 8 bit sprites. Coincidence? Of course not, this will just save us a lot of trouble, as now we can simply copy these from the 8 bit sprites. This will give us the following &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block for the first set of sprites:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is good practice to place the &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block right after the &amp;lt;code&amp;gt;spriteset&amp;lt;code&amp;gt; block it belongs to. Let&#039;s do that and at the same time fill in the other &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And that&#039;s really all there is to defining 32 bit sprites!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Templates ==&lt;br /&gt;
Can we also template 32 bit graphics, I hear you ask? Well certainly, they&#039;re no different than 8 bit sprites in that respect. Let&#039;s go back to where we&#039;ve [[NMLTutorial/Road_vehicle_graphics_template|templated our example road vehicle]]. Because we were smart enough to keep the same positions, sizes and offsets for both our 8 bit and 32 bit sprites, we can simply use the same template we made earlier. This template was called &amp;lt;code&amp;gt;tmpl_truck&amp;lt;/code&amp;gt; and has template parameters for the top left position of the first of eight sprites.&lt;br /&gt;
&lt;br /&gt;
When first using this template, we simply replaced all the numbers inside the spriteset blocks with a call to the template, and ended up with this:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For our &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks we can do the same, there&#039;s really nothing to it:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_empty, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(0, 0)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
alternative_sprites(spriteset_flatbed_truck_1_goods_full, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, &amp;quot;flatbed_truck_1_goods_32.png&amp;quot;, &amp;quot;flatbed_truck_1_goods_mask.png&amp;quot;) {&lt;br /&gt;
    tmpl_truck(260, 0)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the first line of the blocks remains the same, we just replace the content with the template call.&lt;br /&gt;
&lt;br /&gt;
== Other zoom levels ==&lt;br /&gt;
For each additional zoom level, you simply add additional &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|32 bit sprites|Conclusion}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8436</id>
		<title>NMLTutorial/Road vehicle 32 bit sprites</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Road_vehicle_32_bit_sprites&amp;diff=8436"/>
		<updated>2012-06-26T10:51:07Z</updated>

		<summary type="html">&lt;p&gt;FooBar: intermediate save&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve seen that you can add 32 bit sprites, let&#039;s do that with an example. In fact we&#039;re going to pick up halfway down the road vehicle example from the beginning of this tutorial. We&#039;ll continue with what we had at the end of [[NMLTutorial/Road vehicle graphics|this page]].&lt;br /&gt;
&lt;br /&gt;
== Example graphics ==&lt;br /&gt;
We&#039;ll be adding 32 bit graphics for the normal zoom level, including a recolour mask. From there we&#039;ll give you some pointers on how to add sprites for other zoom levels and you can easily fill in the rest yourself. So let&#039;s look at the graphics, shall we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, let&#039;s have a look again at the 8 bit sprites we already have for our road vehicle.&lt;br /&gt;
[[Image:Flatbed truck 1 goods.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The 32 bit sprites are similar to the 8 bit sprites. The main difference is that to indicate transparancy you must use the real transparency of PNG files. If you use the blue background for transparency in 32 bit sprites, you&#039;ll get just that: a blue background. You may also use the alpha channel for semi-transparent pixels.&lt;br /&gt;
[[Image:Flatbed truck 1 goods 32.png|frame|none|Empty flatbed truck sprites and flatbed trucks sprites loaded with a container in 32 bit.]]&lt;br /&gt;
Note that the sprite background is actually transparent. We&#039;ve made the borders around the sprites blue, so that we can actually see where the indivual sprites are. This is not mandatory; as it doesn&#039;t end up in the game, you could have made it any other colour, even transparent if you like. We&#039;ll put this file in the &#039;&#039;gfx&#039;&#039; folder with the regular 8 bit sprites and name it &#039;&#039;Flatbed_truck_1_goods_32.png‎&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now even if you use the exact colours from the palette, this won&#039;t enable company colours in 32 bit sprites. For this you have to provide an additional 8 bit mask sprite, which does use the exact palette colours. Ingame, this mask is overlayed on top of the regular 32 bit sprites, which will give you a company-coloured vehicle. Note that we&#039;ve only drawn the company colours!&lt;br /&gt;
[[Image:Flatbed_truck_1_goods_mask.png|frame|none|The mask file to go with the previous 32 bit graphics]]&lt;br /&gt;
As we&#039;re now drawing in 8 bit again, we also have to use the magic blue to incidate transparent backgrounds! Also this file goes in the &#039;&#039;gfx&#039;&#039; directory and we&#039;ll name it &#039;&#039;Flatbed_truck_1_goods_mask.png&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Spritesets ==&lt;br /&gt;
For the regular 8 bit sprites we have two spritesets in our NML code. Let&#039;s have a look at those again:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
//graphics definition&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_empty, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 0,      0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 16,     0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 48,     0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 96,     0,       20,    16,      -6,        -7]&lt;br /&gt;
    [ 128,    0,        8,    18,      -3,       -10]&lt;br /&gt;
    [ 144,    0,       20,    16,     -14,        -7]&lt;br /&gt;
    [ 176,    0,       28,    12,     -14,        -6]&lt;br /&gt;
    [ 224,    0,       20,    16,      -6,        -7]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_flatbed_truck_1_goods_full, &amp;quot;gfx/flatbed_truck_1_goods.png&amp;quot;) {&lt;br /&gt;
    //left_x, upper_y, width, height, offset_x, offset_y&lt;br /&gt;
    [ 260,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 276,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 308,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 356,    0,       20,    16,      -6,       -7]&lt;br /&gt;
    [ 388,    0,        8,    18,      -3,      -10]&lt;br /&gt;
    [ 404,    0,       20,    16,     -14,       -7]&lt;br /&gt;
    [ 436,    0,       28,    12,     -14,       -6]&lt;br /&gt;
    [ 484,    0,       20,    16,      -6,       -7]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To define our 32 bit sprites, we have to define an &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block to go with each of the spriteset blocks. The identifiers will be the same, we&#039;ll indicate that we have normal zoom sprites via &amp;lt;code&amp;gt;&amp;lt;/code&amp;gt; and that the sprites are 32 bit via &amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|32 bit sprites|Conclusion}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Flatbed_truck_1_goods_mask.png&amp;diff=8435</id>
		<title>File:Flatbed truck 1 goods mask.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Flatbed_truck_1_goods_mask.png&amp;diff=8435"/>
		<updated>2012-06-26T10:44:25Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Example graphics for NML Tutorial. Graphics by DanMack and Zephyris. License: GPL v2 and higher.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example graphics for NML Tutorial. Graphics by DanMack and Zephyris. License: GPL v2 and higher.&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Flatbed_truck_1_goods_32.png&amp;diff=8434</id>
		<title>File:Flatbed truck 1 goods 32.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Flatbed_truck_1_goods_32.png&amp;diff=8434"/>
		<updated>2012-06-26T10:34:57Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Example graphics for NML Tutorial. Graphics by DanMack and Zephyris. License: GPL v2 and higher.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example graphics for NML Tutorial. Graphics by DanMack and Zephyris. License: GPL v2 and higher.&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/32_bit_sprites&amp;diff=8433</id>
		<title>NMLTutorial/32 bit sprites</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/32_bit_sprites&amp;diff=8433"/>
		<updated>2012-06-26T09:59:43Z</updated>

		<summary type="html">&lt;p&gt;FooBar: create page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
As of OpenTTD 1.2.0, 32 bit graphics are to be provided via NewGRF. NML has the ability to add 32 bit sprites to your NewGRF, as well as different sprites for different zoom levels in both 8 bit and 32 bit colour depth. Here we&#039;ll focus on the most common: adding 32 bit sprites for normal, 2x zoom in and 4x zoom in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important:&#039;&#039;&#039; it is mandatory to provide 8 bit sprites for the normal zoom level. You cannot make NewGRFs without the &#039;classic&#039; sprites. If you only have/want 32 bit sprites, this means that you have to do one of the following:&lt;br /&gt;
* Also draw classic 8 bit sprites for your project;&lt;br /&gt;
* Do a simple batch conversion from 32 bit to 8 bit in your graphics editor;&lt;br /&gt;
* Provide transparent 1x1 px sprites for 8 bit normal zoom.&lt;br /&gt;
&lt;br /&gt;
Of course the first option is preferred, as there are always players who want to stick to 8 bit. The last option will break your NewGRF outside of 32 bit blitters, so if you don&#039;t care about 8 bit sprites you still may want to go for the second option.&lt;br /&gt;
&lt;br /&gt;
32 bit sprites in NML are added via &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; blocks. These blocks are similar to &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; blocks and generally appear right after them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Alternative sprites ==&lt;br /&gt;
Like the [[NMLTutorial/Spriteset_and_spritegroup|spriteset]], the &amp;lt;code&amp;gt;alternative_sprites&amp;lt;/code&amp;gt; block defines where sprites can be found in a graphics file, how big these sprites are and what their offsets should be with respect to the ingame bounding box. In addition to the spriteset, alternative_sprites also specifies the colour depth and zoom level for this block. So if you want to provide 32 bit sprites for multiple zoom levels, you&#039;re going to need an alternative_sprites block for each of the zoom levels.&lt;br /&gt;
&lt;br /&gt;
The general syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
alternative_sprites(&amp;lt;identifier&amp;gt;, &amp;lt;zoom_level&amp;gt;, &amp;lt;type&amp;gt; [, &amp;lt;filename&amp;gt; [, &amp;lt;mask_filename&amp;gt;] ] ) {&lt;br /&gt;
	&amp;lt;list_of_realsprites&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;&amp;lt;identifier&amp;gt;&amp;lt;/code&amp;gt; is the same as the identifier for the &amp;lt;code&amp;gt;spriteset&amp;lt;/code&amp;gt; this block provides alternative sprites for. This way you connect the additional sprites to the classic 8 bit sprites. &lt;br /&gt;
*The &amp;lt;code&amp;gt;&amp;lt;zoom_level&amp;gt;&amp;lt;/code&amp;gt; entry sets for what zoom level these sprites are intended. Most used will be &amp;lt;code&amp;gt;ZOOM_LEVEL_NORMAL&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ZOOM_LEVEL_IN_2X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ZOOM_LEVEL_IN_4X&amp;lt;/code&amp;gt;. See the [http://newgrf-specs.tt-wiki.net/wiki/NML:Alternative_sprites NML documentation] for other options.&lt;br /&gt;
* The &amp;lt;code&amp;gt;&amp;lt;type&amp;gt;&amp;lt;/code&amp;gt; indicates if 8 bit or 32 bit sprites are provided. Use either &amp;lt;code&amp;gt;BIT_DEPTH_8BPP&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;BIT_DEPTH_32BPP&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The &amp;lt;code&amp;gt;&amp;lt;filename&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;mask_filename&amp;gt;&amp;lt;/code&amp;gt; are optional. You either provide them here and don&#039;t specify file names for the individual realsprites in this block, or you don&#039;t provide them here and instead provide the filenames for each individual realsprite.&lt;br /&gt;
** The &amp;lt;code&amp;gt;&amp;lt;filename&amp;gt;&amp;lt;/code&amp;gt; is mandatory either here or with the realsprites. Like with a spriteset, it points to the png file with the sprites.&lt;br /&gt;
** The &amp;lt;code&amp;gt;&amp;lt;mask_filename&amp;gt;&amp;lt;/code&amp;gt; is optional either here or with the realsprites. It only applies to 32 bit sprites and points to an 8 bit png file containing the mask for recolouring purposes. You can leave it out if you don&#039;t want recolouring or action colours in your sprites.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;list_of_realsprites&amp;gt; ===&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;list_of_realsprites&amp;gt;&amp;lt;/code&amp;gt; defines the details of each actual sprite. The format is the same as for [[NMLTutorial/Spriteset_and_spritegroup|spriteset]]s:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
[left_x, upper_y, width, height, offset_x, offset_y]&lt;br /&gt;
[left_x, upper_y, width, height, offset_x, offset_y, filename]&lt;br /&gt;
[offset_x, offset_y]&lt;br /&gt;
[offset_x, offset_y, filename]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition to that, the following options are available in case you want to provide a mask file with the individual 32 bit sprites:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
[left_x, upper_y, width, height, offset_x, offset_y, filename, mask_filename]&lt;br /&gt;
[offset_x, offset_y, filename, mask_filename]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consult the tutorial page on [[NMLTutorial/Spriteset_and_spritegroup|spriteset]] for more details on the individual bits and pieces, in case you&#039;ve forgotten.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the next page we&#039;re going to apply this new knowledge to the example road vehicle from the beginning of this tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Object slopes|Road vehicle 32 bit sprites}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Template:NMLTutorial&amp;diff=8432</id>
		<title>Template:NMLTutorial</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Template:NMLTutorial&amp;diff=8432"/>
		<updated>2012-06-26T09:24:13Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Add entries for 32 bit sprites&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;This is the main NML Tutorial navigation template, it is designed to be included in tutorial pages.&amp;lt;/noinclude&amp;gt;&amp;lt;div style=&amp;quot;float:right; padding-left:12px; background:none;&amp;quot;&amp;gt;&amp;lt;div style=&amp;quot;width:180px; border:1px solid #2f6fab; background:#b1cff8; padding:5px; -moz-border-radius-topleft:5px; -moz-border-radius-topright:5px; font-size: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;[[NMLTutorial|NML Tutorial]]&amp;lt;/font&amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #2f6fab; border-top-width: 0px; background:#eaf6f8; padding:5px; font-size: 8pt; line-height: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;[[NMLTutorial/Installation|Installation]]&lt;br /&gt;
;[[NMLTutorial/Graphic files|Graphics files]]&lt;br /&gt;
;[[NMLTutorial/Language files|Language files]]&lt;br /&gt;
;[[NMLTutorial/NML Syntax|NML Syntax]]&lt;br /&gt;
;[[NMLTutorial/Starting an NML file|Starting an NML file (grf block)]]&lt;br /&gt;
*[[NMLTutorial/Road vehicle|Creating a road vehicle]]&lt;br /&gt;
;[[NMLTutorial/Item|Item blocks]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle item definition|Item definition]]&lt;br /&gt;
;[[NMLTutorial/Spriteset and spritegroup|Spriteset &amp;amp; spritegroup blocks]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle graphics|Adding the graphics]]&lt;br /&gt;
;[[NMLTutorial/Template|Template blocks]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle graphics template|Templating the graphics]]&lt;br /&gt;
;[[NMLTutorial/Cargotable|Cargotable block]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle cargo graphics|Cargo-dependent graphics]]&lt;br /&gt;
;[[NMLTutorial/Callback and switch|Callbacks and switch blocks]]&lt;br /&gt;
*[[NMLTutorial/Tram|Creating a tram]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Tram articulation|Make it articulated]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Tram graphics|Adding the graphics]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Tram purchase menu|Fix the purchase menu]]&lt;br /&gt;
&lt;br /&gt;
*[[NMLTutorial/Train|Creating a train]]&lt;br /&gt;
;[[NMLTutorial/Railtypetable|Railtypetable block]]&lt;br /&gt;
**[[NMLTutorial/Train single engine|Single engine]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Train three part articulated|Three part articulated]]&lt;br /&gt;
&lt;br /&gt;
**[[NMLTutorial/Train four part refit|Four part refit]]&lt;br /&gt;
;[[NMLTutorial/Parameters|GRF Parameters]]&lt;br /&gt;
**[[NMLTutorial/Train recolour|Real life recolour scheme]]&lt;br /&gt;
&lt;br /&gt;
*[[NMLTutorial/Object|Creating an object]]&lt;br /&gt;
;[[NMLTutorial/Spritelayout|Spritelayout blocks]]&lt;br /&gt;
**[[NMLTutorial/Object graphics|Adding the graphics]]&lt;br /&gt;
;[[NMLTutorial/Version check|Version checks]]&lt;br /&gt;
**[[NMLTutorial/Object slopes|Objects on slopes]]&lt;br /&gt;
;[[NMLTutorial/32 bit sprites|32 bit sprites]]&lt;br /&gt;
**[[NMLTutorial/Road vehicle 32 bit sprites|Adding 32 bit sprites]]&lt;br /&gt;
;[[NMLTutorial/Conclusion|Conclusion]]&lt;br /&gt;
:[[NMLTutorial/Glossary|Glossary]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #2f6fab; border-top-width: 0px; background:#eaf6f8; padding:5px; font-size: 8pt; line-height: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;[http://newgrf-specs.tt-wiki.net/wiki/NML:Main NML Documentation]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Dutch_Town_Names&amp;diff=8428</id>
		<title>Dutch Town Names</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Dutch_Town_Names&amp;diff=8428"/>
		<updated>2012-06-21T11:12:47Z</updated>

		<summary type="html">&lt;p&gt;FooBar: add links to forum and devzone&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DutchSets}}&lt;br /&gt;
&lt;br /&gt;
[[File:Dutchtownnamesheader.png|link=Dutch Town Names|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dutch Town Names&#039;&#039;&#039; is a NewGRF that provides over 4000 real Dutch town names for use in your games.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
You can get this set from the [http://www.tt-forums.net/viewtopic.php?t=51962 Forums Topic].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Author ==&lt;br /&gt;
Hyronymus&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?t=51962 Downloads]&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?t=51962 Release Topic]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/dutchtowns DevZone project]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Dutch_Town_Names&amp;diff=8427</id>
		<title>Dutch Town Names</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Dutch_Town_Names&amp;diff=8427"/>
		<updated>2012-06-21T10:42:22Z</updated>

		<summary type="html">&lt;p&gt;FooBar: create page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DutchSets}}&lt;br /&gt;
&lt;br /&gt;
[[File:Dutchtownnamesheader.png|link=Dutch Town Names|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dutch Town Names&#039;&#039;&#039; is a NewGRF that provides over 4000 real Dutch town names for use in your games.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
You can get this set from the [http://www.tt-forums.net/viewtopic.php?t=51962 Forums Topic].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Author ==&lt;br /&gt;
Hyronymus&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?t=51962 Downloads]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Dutchtownnamesheader.png&amp;diff=8426</id>
		<title>File:Dutchtownnamesheader.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Dutchtownnamesheader.png&amp;diff=8426"/>
		<updated>2012-06-21T10:40:09Z</updated>

		<summary type="html">&lt;p&gt;FooBar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Dutch_Rail_Furniture&amp;diff=8425</id>
		<title>Dutch Rail Furniture</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Dutch_Rail_Furniture&amp;diff=8425"/>
		<updated>2012-06-21T10:28:59Z</updated>

		<summary type="html">&lt;p&gt;FooBar: create page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DutchSets}}&lt;br /&gt;
&lt;br /&gt;
[[File:Dutchrailfurniturebutton.png|link=Dutch Rail Furiture|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dutch Rail Furnitue&#039;&#039;&#039; is a NewGRF that replaces the default level crossings graphics with Dutch style level crossings. Currently only OpenGFX in the three regular climates is supported. Eventually the [[Dutch Catenary]] and [[Dutch Signals]] will also move to this set.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
OpenTTD users can download this set from the ingame Online Content. If you&#039;re playing TTDPatch or want to install manually, you can get the set from the [http://bundles.openttdcoop.org/dutchrailfurniture/releases/LATEST/ DevZone].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Authors ==&lt;br /&gt;
* Graphics: Purno&lt;br /&gt;
* Code: FooBar&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
* [http://bundles.openttdcoop.org/dutchrailfurniture/releases/LATEST/ Downloads]&lt;br /&gt;
* [http://dev.openttdcoop.org/projects/dutchrailfurniture DevZone project]&lt;br /&gt;
* [http://www.tt-forums.net/viewtopic.php?t=58880 Development topic]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=File:Dutchrailfurniturebutton.png&amp;diff=8424</id>
		<title>File:Dutchrailfurniturebutton.png</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=File:Dutchrailfurniturebutton.png&amp;diff=8424"/>
		<updated>2012-06-21T10:21:28Z</updated>

		<summary type="html">&lt;p&gt;FooBar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Template:DutchSets&amp;diff=8418</id>
		<title>Template:DutchSets</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Template:DutchSets&amp;diff=8418"/>
		<updated>2012-06-20T21:40:09Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Add entry for Dutch Rail Furniture&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;This is the main navigation template for Dutch Set pages.&amp;lt;/noinclude&amp;gt;&amp;lt;div style=&amp;quot;float:right; padding-left:12px; background:none;&amp;quot;&amp;gt;&amp;lt;div style=&amp;quot;width:180px; border:1px solid #F90; border-bottom: none; background:#C00; color:#FFF; padding:5px; -moz-border-radius-topleft:8px; -moz-border-radius-topright:8px; font-size: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;Dutch Sets&amp;lt;/font&amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #F90; border-top: none; border-bottom: none; background:#FFF; padding:5px; font-size: 8pt; line-height: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Rail sets&lt;br /&gt;
:[[Dutch Trainset 2]]&lt;br /&gt;
:: [[Dutch Trainset 2/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Trainset 2/Vehicles|Vehicles]]&lt;br /&gt;
:[[Dutch Stationset|Dutch Stations]]&lt;br /&gt;
:: [[Dutch Stations/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Stations/Stations|Stations]]&lt;br /&gt;
:[[Dutch Track Set]]&lt;br /&gt;
:: [[Dutch Track Set/Handbook|Handbook]]&lt;br /&gt;
:[[Dutch Rail Furniture]]&lt;br /&gt;
:[[Dutch Catenary]]&lt;br /&gt;
:[[Dutch Signals]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Road sets&lt;br /&gt;
:[[Dutch Tram Set 2]]&lt;br /&gt;
:: [[Dutch Tram Set 2/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Tram Set 2/Vehicles|Vehicles]]&lt;br /&gt;
:[[Dutch Road Furniture]]&lt;br /&gt;
:: [[Dutch Road Furniture/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Road Furniture/Objects|Objects]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Other sets&lt;br /&gt;
:[[Dutch Town Names]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Deprecated sets&lt;br /&gt;
:[[Dutch Trainset|Dutch Trainset 1]]&lt;br /&gt;
:[[Dutch Trainset Cargo Extension]]&lt;br /&gt;
:[[Dutch Tram Set|Dutch Tram Set 1]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #F90; border-top: none; background:#009; padding:5px; font-size: 8pt; line-height: 12pt; text-align:center;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;[[Dutch Sets|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main Page&amp;lt;/span&amp;gt;]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
[[Category:Dutch]]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Dutch_Sets&amp;diff=8417</id>
		<title>Dutch Sets</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Dutch_Sets&amp;diff=8417"/>
		<updated>2012-06-20T21:36:39Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Add entry for Dutch Rail Furniture&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DutchSets}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
Welcome to the main entry page for all Dutch NewGRFs. The menu at the right will help you navigate through the different sections with background information, screenshots and guides. The table below gives an overview of all Dutch Sets and their compatibility with OpenTTD and TTDPatch.&lt;br /&gt;
&lt;br /&gt;
For some time it has been possible to replace the original graphics in Transport Tycoon Deluxe with self-made graphics. This was first accomplished by Patchman with his releases of [http://www.ttdpatch.net/ TTDPatch]. Later on things got even more exciting when [http://www.openttd.org/ OpenTTD] was released, a clone of Transport Tycoon Deluxe completely rewritten in C.&lt;br /&gt;
&lt;br /&gt;
One of the first artists to develop a comprehensive graphics set to replace original game graphics was Michael Blunck. Inspired by his DBSet with German trains a group of people on the [http://www.tt-forums.net/ TT-forums] community decided it was time for a Dutch trainset. After keeping the public in suspense for quite some time version 1.0 was released on March 1st, 2009.&lt;br /&gt;
&lt;br /&gt;
In the mean time other people started work on a Dutch Stationset and a Dutch Tramset. In between Purno managed to squeeze out Dutch signals and Dutch catenary. All of these graphics are available for download in NewGRF format. You will find links to the sets in the menu to the right. The tables below give a quick overview of all that we have available for you. If you&#039;re interested in the details behind each set we highly recommend you to browse through the various set&#039;s pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rail related NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Trainset 2&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:DTSnew3.PNG|link=Dutch Trainset 2]] || Version 2.0.0-alpha5 || Released June 20th, 2012&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] 1.2.0-RC1 or higher || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchtrains/releases/LATEST/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Trainset 2|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Trainset 2/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Trainset 2/Vehicles|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtrains &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=59353 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?f=26&amp;amp;t=5033 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Station Set&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchstationsetbutton.png|link=Dutch Stationset]] || Version 1.0.0 || Released April 25th, 2008&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchstations/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchstations/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Stationset|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Stations/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Stations/Stations|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Stations&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchstations &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?f=26&amp;amp;t=23638 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Track Set&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtracksetbutton.png|link=Dutch Track Set]] || - || Not yet released&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Track Set|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Track Set/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtracks &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=59201 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Rail Furniture&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchrailfurniturebutton.png|link=Dutch Rail Furniture]] || Version 0.1.0 || Released June 20th, 2012&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] 1.2.0-RC1 or higher || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchrailfurniture/releases/LATEST/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Rail Furniture|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchrailfurniture&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=58880 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Catenary&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchcatenarybutton.png|link=Dutch Catenary]] || Version 1.0.0 || Released April 20th, 2006&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchcatenary-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchcatenary-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Catenary|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Signals&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchsignalsbutton.png|link=Dutch Signals]] || Version 1.0.0 || Released May 3rd, 2006&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchsignals-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchsignals-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Signals|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Road related NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Tram Set 2&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtramsetheader.png|link=Dutch Tram Set 2]] || Version 2.0.0 || Released January 1st, 2012&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] 1.2.0-beta1 or higher || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchtramset/releases/LATEST/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Tram Set 2|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Tram Set 2/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Tram Set 2/Vehicles|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtramset &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=45456 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=33180 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Road Furniture&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchroadfurniturebutton.png|link=Dutch Road Furniture]] || Version 0.6.0 || Released January 19th, 2012&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] 1.2.0-beta4 or higher || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchroadfurniture/releases/LATEST/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Road Furniture|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Road Furniture/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Road Furniture/Objects|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Objects&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchroadfurniture &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=58107 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=56316 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Other NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Town Names&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtownnamesheader.png|link=Dutch Town Names]] || Version 1 || Released December 22nd, 2010&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [http://www.tt-forums.net/viewtopic.php?t=51962 TT-Forums topic]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not specified || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Town Names|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtowns &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=51962 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Deprecated NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Trainset&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtrainsetbutton.png|link=Dutch Trainset]] || Version 1.0.0 || Released March 1st, 2009&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchtrains/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchtrains/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Trainset|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/Screenshots|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Screenshots&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/Locomotives|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles: Locomotives&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/MUs|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles: Multiple Units&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/Wagons|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles: Coaches&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Trainset Cargo Extension&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtrainsetcargoextensionbutton.png|link=Dutch Trainset Cargo Extension]] || Version 1.0.0 || Released July 20th, 2011&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://www.tt-forums.net/viewtopic.php?t=55872 TT-Forums]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Trainset Cargo Extension|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Tram Set&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtramsetbutton.png|link=Dutch Tram Set]] || Version 1.0.0-RC1 || Released October 11th, 2009&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [http://www.tt-forums.net/viewtopic.php?p=609644#p609644 TT-Forums]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://www.tt-forums.net/viewtopic.php?p=609644#p609644 TT-Forums]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Tram Set|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
;Transport Tycoon (Deluxe) and OpenTTD&lt;br /&gt;
*[http://grfcrawler.tt-forums.net Oskar&#039;s Grfcrawler (an index of graphics sets)]&lt;br /&gt;
*[http://ttdpatch.de/download/ Website of Michael Blunck&#039;s graphics sets]&lt;br /&gt;
*[http://www.tt-forums.net THE forums to talk about Transport Tycoon Deluxe and related games]&lt;br /&gt;
*[http://www.ttdpatch.net Website of Josef Drexler&#039;s TTDPatch]&lt;br /&gt;
*[http://www.openttd.org OpenTTD, an Open Source Transport Tycoon Deluxe Clone]&lt;br /&gt;
&lt;br /&gt;
;Resource websites (mostly in Dutch)&lt;br /&gt;
*[http://www.spoorwegmuseum.nl Website of the Dutch Railway Museum]&lt;br /&gt;
*[http://www.gotischeboog.com/ Website of the &#039;Gotische Boog&#039; H0 module group]&lt;br /&gt;
*[http://home.hccnet.nl/pj.klarenbeek/nl/ns/submenu.html A site with sideviews of many Dutch rolling stock]&lt;br /&gt;
*[http://www.nicospilt.com/ Website of Nico Spilt, contains large amounts of images (both Dutch and foreign trains)]&lt;br /&gt;
*[http://www.arthurstreinenpagina.nl/ Website with many drawings of trains and a screensaver!]&lt;br /&gt;
*[http://www.railfaneurope.net/ The largest database of European train images]&lt;br /&gt;
*[http://www.modelspoormuseum.nl Website of the Dutch Model Railway Museum]&lt;br /&gt;
*[http://www.seinarm.nl/ Website with detailed information on MUs and wagons, as well as the Dutch signalling system]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Template:DutchSets&amp;diff=8383</id>
		<title>Template:DutchSets</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Template:DutchSets&amp;diff=8383"/>
		<updated>2012-06-03T13:22:13Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Add entry for Dutch Town Names&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;This is the main navigation template for Dutch Set pages.&amp;lt;/noinclude&amp;gt;&amp;lt;div style=&amp;quot;float:right; padding-left:12px; background:none;&amp;quot;&amp;gt;&amp;lt;div style=&amp;quot;width:180px; border:1px solid #F90; border-bottom: none; background:#C00; color:#FFF; padding:5px; -moz-border-radius-topleft:8px; -moz-border-radius-topright:8px; font-size: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;font size=&amp;quot;3&amp;quot;&amp;gt;Dutch Sets&amp;lt;/font&amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #F90; border-top: none; border-bottom: none; background:#FFF; padding:5px; font-size: 8pt; line-height: 12pt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Rail sets&lt;br /&gt;
:[[Dutch Trainset 2]]&lt;br /&gt;
:: [[Dutch Trainset 2/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Trainset 2/Vehicles|Vehicles]]&lt;br /&gt;
:[[Dutch Stationset|Dutch Stations]]&lt;br /&gt;
:: [[Dutch Stations/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Stations/Stations|Stations]]&lt;br /&gt;
:[[Dutch Track Set]]&lt;br /&gt;
:: [[Dutch Track Set/Handbook|Handbook]]&lt;br /&gt;
:[[Dutch Catenary]]&lt;br /&gt;
:[[Dutch Signals]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Road sets&lt;br /&gt;
:[[Dutch Tram Set 2]]&lt;br /&gt;
:: [[Dutch Tram Set 2/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Tram Set 2/Vehicles|Vehicles]]&lt;br /&gt;
:[[Dutch Road Furniture]]&lt;br /&gt;
:: [[Dutch Road Furniture/Handbook|Handbook]]&lt;br /&gt;
:: [[Dutch Road Furniture/Objects|Objects]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Other sets&lt;br /&gt;
:[[Dutch Town Names]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Deprecated sets&lt;br /&gt;
:[[Dutch Trainset|Dutch Trainset 1]]&lt;br /&gt;
:[[Dutch Trainset Cargo Extension]]&lt;br /&gt;
:[[Dutch Tram Set|Dutch Tram Set 1]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:180px;  border:1px solid #F90; border-top: none; background:#009; padding:5px; font-size: 8pt; line-height: 12pt; text-align:center;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;[[Dutch Sets|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main Page&amp;lt;/span&amp;gt;]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
[[Category:Dutch]]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Dutch_Sets&amp;diff=8382</id>
		<title>Dutch Sets</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Dutch_Sets&amp;diff=8382"/>
		<updated>2012-06-03T13:21:15Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Add entry for Dutch Town Names&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DutchSets}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
Welcome to the main entry page for all Dutch NewGRFs. The menu at the right will help you navigate through the different sections with background information, screenshots and guides. The table below gives an overview of all Dutch Sets and their compatibility with OpenTTD and TTDPatch.&lt;br /&gt;
&lt;br /&gt;
For some time it has been possible to replace the original graphics in Transport Tycoon Deluxe with self-made graphics. This was first accomplished by Patchman with his releases of [http://www.ttdpatch.net/ TTDPatch]. Later on things got even more exciting when [http://www.openttd.org/ OpenTTD] was released, a clone of Transport Tycoon Deluxe completely rewritten in C.&lt;br /&gt;
&lt;br /&gt;
One of the first artists to develop a comprehensive graphics set to replace original game graphics was Michael Blunck. Inspired by his DBSet with German trains a group of people on the [http://www.tt-forums.net/ TT-forums] community decided it was time for a Dutch trainset. After keeping the public in suspense for quite some time version 1.0 was released on March 1st, 2009.&lt;br /&gt;
&lt;br /&gt;
In the mean time other people started work on a Dutch Stationset and a Dutch Tramset. In between Purno managed to squeeze out Dutch signals and Dutch catenary. All of these graphics are available for download in NewGRF format. You will find links to the sets in the menu to the right. The tables below give a quick overview of all that we have available for you. If you&#039;re interested in the details behind each set we highly recommend you to browse through the various set&#039;s pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rail related NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Trainset 2&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:DTSnew3.PNG|link=Dutch Trainset 2]] || Version 2.0.0-alpha1 || Released April 1st, 2012&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] 1.2.0-RC1 or higher || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchtrains/releases/LATEST/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Trainset 2|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Trainset 2/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Trainset 2/Vehicles|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtrains &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=59353 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?f=26&amp;amp;t=5033 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Station Set&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchstationsetbutton.png|link=Dutch Stationset]] || Version 1.0.0 || Released April 25th, 2008&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchstations/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchstations/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Stationset|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Stations/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Stations/Stations|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Stations&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchstations &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?f=26&amp;amp;t=23638 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Track Set&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtracksetbutton.png|link=Dutch Track Set]] || - || Not yet released&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Track Set|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Track Set/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtracks &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=59201 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Catenary&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchcatenarybutton.png|link=Dutch Catenary]] || Version 1.0.0 || Released April 20th, 2006&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchcatenary-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchcatenary-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Catenary|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Signals&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchsignalsbutton.png|link=Dutch Signals]] || Version 1.0.0 || Released May 3rd, 2006&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchsignals-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchrailfurniture/releases/dutchsignals-1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Signals|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Road related NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Tram Set 2&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtramsetheader.png|link=Dutch Tram Set 2]] || Version 2.0.0 || Released January 1st, 2012&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] 1.2.0-beta1 or higher || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchtramset/releases/LATEST/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Tram Set 2|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Tram Set 2/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Tram Set 2/Vehicles|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtramset &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=45456 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=33180 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Road Furniture&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchroadfurniturebutton.png|link=Dutch Road Furniture]] || Version 0.6.0 || Released January 19th, 2012&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] 1.2.0-beta4 or higher || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchroadfurniture/releases/LATEST/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Road Furniture|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Road Furniture/Handbook|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Handbook&amp;lt;/span&amp;gt;]] | [[Dutch Road Furniture/Objects|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Objects&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchroadfurniture &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=58107 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=56316 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Development topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Other NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Town Names&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtownnamesheader.png|link=Dutch Town Names]] || Version 1 || Released December 22nd, 2010&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [http://www.tt-forums.net/viewtopic.php?t=51962 TT-Forums topic]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not specified || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Town Names|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:right&amp;quot;&amp;gt;[http://dev.openttdcoop.org/projects/dutchtowns &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;DevZone project&amp;lt;/span&amp;gt;] | [http://www.tt-forums.net/viewtopic.php?t=51962 &amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Release topic&amp;lt;/span&amp;gt;]&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Deprecated NewGRFs ==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Trainset&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtrainsetbutton.png|link=Dutch Trainset]] || Version 1.0.0 || Released March 1st, 2009&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://bundles.openttdcoop.org/dutchtrains/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://bundles.openttdcoop.org/dutchtrains/releases/1.0.0/ DevZone]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Trainset|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/Screenshots|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Screenshots&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/Locomotives|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles: Locomotives&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/MUs|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles: Multiple Units&amp;lt;/span&amp;gt;]] | [[Dutch Trainset/Wagons|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Vehicles: Coaches&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Trainset Cargo Extension&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtrainsetcargoextensionbutton.png|link=Dutch Trainset Cargo Extension]] || Version 1.0.0 || Released July 20th, 2011&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [[ottdwiki:Online content|Online Content]] or [http://www.tt-forums.net/viewtopic.php?t=55872 TT-Forums]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] not compatible || -&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Trainset Cargo Extension|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:700px;margin-top:16px;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#C00; color:#FFF&amp;quot; | Dutch Tram Set&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; style=&amp;quot;padding:4px;width:311px&amp;quot; | [[File:Dutchtramsetbutton.png|link=Dutch Tram Set]] || Version 1.0.0-RC1 || Released October 11th, 2009&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:160px&amp;quot; | [[File:Openttd_icon.png|OpenTTD compatible|link=]] compatible || [http://www.tt-forums.net/viewtopic.php?p=609644#p609644 TT-Forums]&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Ttdpatch_icon.png|TTDPatch compatible|link=]] compatible || [http://www.tt-forums.net/viewtopic.php?p=609644#p609644 TT-Forums]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; style=&amp;quot;background-color:#00C; color:#FFF&amp;quot; | [[Dutch Tram Set|&amp;lt;span style=&amp;quot;color:#FFF&amp;quot;&amp;gt;Main page&amp;lt;/span&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
;Transport Tycoon (Deluxe) and OpenTTD&lt;br /&gt;
*[http://grfcrawler.tt-forums.net Oskar&#039;s Grfcrawler (an index of graphics sets)]&lt;br /&gt;
*[http://ttdpatch.de/download/ Website of Michael Blunck&#039;s graphics sets]&lt;br /&gt;
*[http://www.tt-forums.net THE forums to talk about Transport Tycoon Deluxe and related games]&lt;br /&gt;
*[http://www.ttdpatch.net Website of Josef Drexler&#039;s TTDPatch]&lt;br /&gt;
*[http://www.openttd.org OpenTTD, an Open Source Transport Tycoon Deluxe Clone]&lt;br /&gt;
&lt;br /&gt;
;Resource websites (mostly in Dutch)&lt;br /&gt;
*[http://www.spoorwegmuseum.nl Website of the Dutch Railway Museum]&lt;br /&gt;
*[http://www.gotischeboog.com/ Website of the &#039;Gotische Boog&#039; H0 module group]&lt;br /&gt;
*[http://home.hccnet.nl/pj.klarenbeek/nl/ns/submenu.html A site with sideviews of many Dutch rolling stock]&lt;br /&gt;
*[http://www.nicospilt.com/ Website of Nico Spilt, contains large amounts of images (both Dutch and foreign trains)]&lt;br /&gt;
*[http://www.arthurstreinenpagina.nl/ Website with many drawings of trains and a screensaver!]&lt;br /&gt;
*[http://www.railfaneurope.net/ The largest database of European train images]&lt;br /&gt;
*[http://www.modelspoormuseum.nl Website of the Dutch Model Railway Museum]&lt;br /&gt;
*[http://www.seinarm.nl/ Website with detailed information on MUs and wagons, as well as the Dutch signalling system]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_recolour&amp;diff=8342</id>
		<title>NMLTutorial/Train recolour</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_recolour&amp;diff=8342"/>
		<updated>2012-05-03T16:54:56Z</updated>

		<summary type="html">&lt;p&gt;FooBar: use length instead of shorten_vehicle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the [http://dev.openttdcoop.org/projects/nml/repository/show/examples NML source]. The code for this was originally written in NFO by DJNekkid for the 2cc Trainset and rewritten in NML by Hirundo. The graphics used in the example are by Purno. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues and concludes the [[NMLTutorial/Train four part refit|fourth part]] of the train example. A parameter setting will be added (with a GUI for OpenTTD) to allow choosing between 1cc, 2cc or real life colours for our train. And we&#039;ll do some further visual improvements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== GRF Parameter setting ==&lt;br /&gt;
The GRF parameter setting will allow choosing between 1cc, 2cc or real life colours. This is done by adding a param block to the grf block. In this param block one (named) parameter will be defined:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
    param {&lt;br /&gt;
        /* There is one parameter, which can be used to alter the colour scheme */&lt;br /&gt;
        param_colour_scheme {&lt;br /&gt;
            type: int;&lt;br /&gt;
            name: string(STR_PARAM_COLOUR_SCHEME_NAME);&lt;br /&gt;
            desc: string(STR_PARAM_COLOUR_SCHEME_DESC);&lt;br /&gt;
            /* There are currently three possible values:&lt;br /&gt;
             * - 1cc&lt;br /&gt;
             * - 2cc (default)&lt;br /&gt;
             * - real-world&lt;br /&gt;
             */&lt;br /&gt;
            min_value: 0;&lt;br /&gt;
            max_value: 2;&lt;br /&gt;
            def_value: 1;&lt;br /&gt;
            names: {&lt;br /&gt;
                0: string(STR_PARAM_COLOUR_SCHEME_1CC);&lt;br /&gt;
                1: string(STR_PARAM_COLOUR_SCHEME_2CC);&lt;br /&gt;
                2: string(STR_PARAM_COLOUR_SCHEME_REAL);&lt;br /&gt;
            };&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GRF parameter is named &amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt;. This identifier needs to be unique and can be used elsewhere in the code to make decisions upon. Because we want three possible values, the GRF parameter needs to be of the integer type. The boolean type wouldn&#039;t work, as that only allows two possible values (on and off). The minimum value will be 0, the maximum 2 (resulting in three possible values 0, 1 and 2) and the default (in OpenTTD, TTDPatch always defaults to 0) will be 1. Strings are defined for the GRF parameter name and description. Each GRF parameter value will also get custom strings to display the settings rather than just numbers.&lt;br /&gt;
&lt;br /&gt;
This means we have to add these strings to the language file as well:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_NAME :Colour scheme&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_DESC :Select the type of colour scheme to use&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_1CC  :One company colour&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_2CC  :Two company colours&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_REAL :Real-world colours&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Colour mapping callback ==&lt;br /&gt;
This only added the parameter setting, but it doesn&#039;t do anything yet. We&#039;ll use the &amp;lt;code&amp;gt;colour_mapping&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback]. This callback allows recolouring a sprite using, well errr, recolour sprites. This is a slightly complicated callback, but the first step is easy. Reference a switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
        colour_mapping:               sw_icm_colour_mapping;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself we&#039;ll just give to you, attempting to explain what it does afterwards. If you don&#039;t understand how this switch block works, just copy it or ignore the callback altogether. Try yourself at some more easy NewGRFs first to get the hang of NML and come back to this later.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_colour_mapping, param_colour_scheme) {&lt;br /&gt;
    /* Emulate 1cc by making the first colour always yellow, this looks much better (and more realistic) */&lt;br /&gt;
    0: return palette_2cc(COLOUR_YELLOW, company_colour1);&lt;br /&gt;
    /* Use realistic colours, i.e. yellow + dark blue */&lt;br /&gt;
    2: return palette_2cc(COLOUR_YELLOW, COLOUR_DARK_BLUE);&lt;br /&gt;
    /* Use the default, i.e. 2 company colours */&lt;br /&gt;
    return base_sprite_2cc + CB_RESULT_COLOUR_MAPPING_ADD_CC;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The decision of this switch block is made on the &amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt;. The name of this variable is what we gave to it when defining the param block, so that&#039;s how you use a predefined GRF parameter. The values this GRF parameter can have are those defined in the same param block, so these values can be used as range in the switch block. It&#039;s useful to consider one value as default here, in case a user manages to make a setting outside the range of the minimum and maximum GRF parameter setting.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;colour_mapping&amp;lt;/code&amp;gt; needs to return the sprite number of a recolour sprite. We&#039;ll be using the default recolour sprites for this and NML has some functions and variables to retrieve these sprite numbers for you. You can find more about that in the [http://newgrf-specs.tt-wiki.net/wiki/NML:List_of_default_colour_translation_palettes NML Documentation].&lt;br /&gt;
; 1cc (&amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt; == 0)&lt;br /&gt;
: Here we use the &amp;lt;code&amp;gt;palette_2cc&amp;lt;/code&amp;gt; function even though we only want 1cc. To make the train look better we make one of the two company colours yellow rather than keeping the normal company colour range, using the &amp;lt;code&amp;gt;COLOUR_YELLOW&amp;lt;/code&amp;gt; from the default [http://newgrf-specs.tt-wiki.net/wiki/NML:List_of_default_colour_translation_palettes#Company_colour_helper_functions colour constants]. The other company colour will depend on what first company colour the user has selected, which we&#039;ll get from the &amp;lt;code&amp;gt;company_colour1&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables vehicle variable].&lt;br /&gt;
; real life colours (&amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt; == 2)&lt;br /&gt;
: The real life colours of this Dutch NS train are blue and yellow. We can force the train to be recoloured in these colours regardless of the company colours selected by the user. This is similar to the 1cc recolour from above, but now we return two specific colours rather than depend on the company colour variable.&lt;br /&gt;
; 2cc (default)&lt;br /&gt;
: This is what will be used as default if the GRF parameter setting is not equal to 0 or 2. Here a different way of returning the recolour sprite is used. The sprite number of the first 2cc recolour sprite can be found with the &amp;lt;code&amp;gt;base_sprite_2cc&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:General#General_variables variable]. Add &amp;lt;code&amp;gt;CB_RESULT_COLOUR_MAPPING_ADD_CC&amp;lt;/code&amp;gt; to this (see the [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback description]) to find the company colours used.&lt;br /&gt;
&lt;br /&gt;
With that the GRF parameter setting to choose the vehicle colours is done.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Visual effect ==&lt;br /&gt;
The train currently has a visual effect (electric spark) on all parts of the vehicle, but only the first part has a pantograph. We can limit the effect to only this first part by using the &amp;lt;code&amp;gt;visual_effect_and_powered&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback]. Making a decision only on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] we can do this using a conditional assignment directly from the graphics block without the need for a switch block:&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
        visual_effect_and_powered:    return (position_in_consist % 4 == 0) ?&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER) :&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the first part of the vehicle we return the electric spark [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Train_properties visual effect] with an offset of 2 and not making this a powered wagon. For all other parts we disable the visual effect (offset doesn&#039;t matter now) and also not make this a powered wagon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lights out ==&lt;br /&gt;
There&#039;s one more thing that can be improved about this train. We still have not used the sprites that show no lights at the front and rear of the train. It would be nice if two EMUs are coupled that there are no lights on where the coupling is, only at the front and back.&lt;br /&gt;
&lt;br /&gt;
For this we have to change the graphics switch block, not referencing the spritesets for back and front directly, but using an intermediate switch block to decide if we want lights or not.&lt;br /&gt;
&lt;br /&gt;
Change the current switch block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      sw_icm_graphics_front;&lt;br /&gt;
    3:      sw_icm_graphics_rear;&lt;br /&gt;
    sw_icm_graphics_middle;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This now links to two additional switch blocks, one for the front and one for the rear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
/* Only the frontmost vehicle should have its lights on */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_front, position_in_consist) {&lt;br /&gt;
    0: set_icm_front_lighted;&lt;br /&gt;
    set_icm_front;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Only the rearmost vehicle should have red lights */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_rear, position_in_consist_from_end) {&lt;br /&gt;
    0: set_icm_rear_lighted;&lt;br /&gt;
    set_icm_rear;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case of the front part, we make a decision based on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. If it&#039;s the very first of the consist, show front lights, otherwise show no front lights for further connected EMUs.&lt;br /&gt;
&lt;br /&gt;
In case of the last part, we make a decision based on the &amp;lt;code&amp;gt;position_in_consist_from_end&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. This counts exactly opposite than &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt;, now starting from the back. If it&#039;s the very last of the consist, show rear lights, otherwise show no rear lights for further connected EMUs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Total code ==&lt;br /&gt;
When put in the correct order, this should now encode as a working NewGRF. The total code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example small&amp;quot;&amp;gt;&lt;br /&gt;
/* Define grf */&lt;br /&gt;
grf {&lt;br /&gt;
    grfid: &amp;quot;NML\00&amp;quot;;&lt;br /&gt;
    /* GRF name and description strings are defined in the lang files */&lt;br /&gt;
    name: string(STR_GRF_NAME);&lt;br /&gt;
    desc: string(STR_GRF_DESC);&lt;br /&gt;
    /* This is the first version, start numbering at 0. */&lt;br /&gt;
    version: 0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
&lt;br /&gt;
    /* Define user-configurable parameters */&lt;br /&gt;
    param {&lt;br /&gt;
        /* There is one parameter, which can be used to alter the colour scheme */&lt;br /&gt;
        param_colour_scheme {&lt;br /&gt;
            type: int;&lt;br /&gt;
            name: string(STR_PARAM_COLOUR_SCHEME_NAME);&lt;br /&gt;
            desc: string(STR_PARAM_COLOUR_SCHEME_DESC);&lt;br /&gt;
            /* There are currently three possible values:&lt;br /&gt;
             * - 1cc&lt;br /&gt;
             * - 2cc (default)&lt;br /&gt;
             * - real-world&lt;br /&gt;
             */&lt;br /&gt;
            min_value: 0;&lt;br /&gt;
            max_value: 2;&lt;br /&gt;
            def_value: 1;&lt;br /&gt;
            names: {&lt;br /&gt;
                0: string(STR_PARAM_COLOUR_SCHEME_1CC);&lt;br /&gt;
                1: string(STR_PARAM_COLOUR_SCHEME_2CC);&lt;br /&gt;
                2: string(STR_PARAM_COLOUR_SCHEME_REAL);&lt;br /&gt;
            };&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define a rail type table,&lt;br /&gt;
 * this allows referring to railtypes&lt;br /&gt;
 * irrespective of the grfs loaded.&lt;br /&gt;
 */&lt;br /&gt;
railtypetable {&lt;br /&gt;
    ELRL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Basic template for 4 vehicle views */&lt;br /&gt;
template tmpl_vehicle_basic(x, y) {&lt;br /&gt;
    // arguments x, y: coordinates of top-left corner of first sprite&lt;br /&gt;
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xrel yrel&lt;br /&gt;
    [x +  9, y, 22, 20, -14, -12]&lt;br /&gt;
    [x + 32, y, 32, 16, -16, -12]&lt;br /&gt;
    [x + 65, y, 22, 20,  -6, -12]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with only 4 views (symmetric) */&lt;br /&gt;
template tmpl_vehicle_4_views(num) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    tmpl_vehicle_basic(1, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with 8 views (non-symmetric) */&lt;br /&gt;
template tmpl_vehicle_8_views(num, reversed) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    // argument reversed: Reverse visible orientation of vehicle, if set to 1&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a single vehicle sprite */&lt;br /&gt;
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {&lt;br /&gt;
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the spritesets, these allow referring to these sprites later on */&lt;br /&gt;
spriteset (set_icm_front_lighted, &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(0, 0) }&lt;br /&gt;
spriteset (set_icm_rear_lighted,  &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(1, 1) }&lt;br /&gt;
spriteset (set_icm_front,         &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(2, 0) }&lt;br /&gt;
spriteset (set_icm_rear,          &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(3, 1) }&lt;br /&gt;
spriteset (set_icm_middle,        &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_4_views(4)    }&lt;br /&gt;
spriteset (set_icm_purchase,      &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(5, 53, 14, -25, -10) }&lt;br /&gt;
spriteset (set_icm_invisible,     &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(6,  1,  1,   0,   0) }&lt;br /&gt;
&lt;br /&gt;
/* --- Graphics callback  --- */&lt;br /&gt;
&lt;br /&gt;
/* Only the frontmost vehicle should have its lights on */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_front, position_in_consist) {&lt;br /&gt;
    0: set_icm_front_lighted;&lt;br /&gt;
    set_icm_front;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Only the rearmost vehicle should have red lights */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_rear, position_in_consist_from_end) {&lt;br /&gt;
    0: set_icm_rear_lighted;&lt;br /&gt;
    set_icm_rear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* In the 3-part version, the 3rd car is invisible */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_middle, ((position_in_consist % 4) == 2) &amp;amp;&amp;amp; (cargo_subtype == 0)) {&lt;br /&gt;
    1: set_icm_invisible;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      sw_icm_graphics_front;&lt;br /&gt;
    3:      sw_icm_graphics_rear;&lt;br /&gt;
    sw_icm_graphics_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Cargo subtype text --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_cargo_subtype_text, cargo_subtype) {&lt;br /&gt;
    0: return string(STR_ICM_SUBTYPE_3_PART);&lt;br /&gt;
    1: return string(STR_ICM_SUBTYPE_4_PART);&lt;br /&gt;
    return 0xFF;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Colour mapping callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_colour_mapping, param_colour_scheme) {&lt;br /&gt;
    /* Emulate 1cc by making the first colour always yellow, this looks much better (and more realistic) */&lt;br /&gt;
    0: return palette_2cc(COLOUR_YELLOW, company_colour1);&lt;br /&gt;
    /* Use realistic colours, i.e. yellow + dark blue */&lt;br /&gt;
    2: return palette_2cc(COLOUR_YELLOW, COLOUR_DARK_BLUE);&lt;br /&gt;
    /* Use the default, i.e. 2 company colours */&lt;br /&gt;
    return base_sprite_2cc + CB_RESULT_COLOUR_MAPPING_ADD_CC;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Articulated part callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add three articulated parts, for a total of four */&lt;br /&gt;
    1 .. 3: return item_icm;&lt;br /&gt;
    return 0xFF;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Start/stop callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12-16 cars) */&lt;br /&gt;
    1 .. 16: return 0xFF;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Wagon attach callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_can_attach_wagon, vehicle_type_id) {&lt;br /&gt;
    /* SELF refers to the wagon here, check that it&#039;s an ICM */&lt;br /&gt;
    item_icm: return CB_RESULT_ATTACH_ALLOW;&lt;br /&gt;
    return string(STR_ICM_CANNOT_ATTACH_OTHER);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Shorten vehicle callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_3_part_vehicle, position_in_consist % 4) {&lt;br /&gt;
    /* In the three part version, shorten the 2nd vehicle to 7/8 and the 3rd to 1/8&lt;br /&gt;
     * The rear (1/8) part is then made invisisble */&lt;br /&gt;
    1: return 7;&lt;br /&gt;
    2: return 1;&lt;br /&gt;
    return 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_vehicle, cargo_subtype) {&lt;br /&gt;
    0: sw_icm_shorten_3_part_vehicle;&lt;br /&gt;
    return 8; // 4-part vehicle needs no shortening&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Power, weight and TE are all applied to the front vehicle only */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_power, cargo_subtype) {&lt;br /&gt;
    0: return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
    return int(1890 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_weight, cargo_subtype) {&lt;br /&gt;
    0: return 144; //ton, 3 part train&lt;br /&gt;
    return 192; //ton, 4 part train&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_te, cargo_subtype) {&lt;br /&gt;
    /* Base TE coefficient = 0.3&lt;br /&gt;
     * 3 parts: 4/12 of weight on driving wheels&lt;br /&gt;
     * 4 parts: 6/16 of weight on driving wheels */&lt;br /&gt;
    0: return int(0.3 * 255 / 3);&lt;br /&gt;
    return int(0.3 * 255 * 3 / 8);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the actual train */&lt;br /&gt;
item(FEAT_TRAINS, item_icm) {&lt;br /&gt;
    /* Define properties first, make sure to set all of them */&lt;br /&gt;
    property {&lt;br /&gt;
        name:                         string(STR_ICM_NAME);&lt;br /&gt;
        // not available in toyland:&lt;br /&gt;
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); &lt;br /&gt;
        introduction_date:            date(1983, 1, 1);&lt;br /&gt;
        model_life:                   VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        vehicle_life:                 30;&lt;br /&gt;
        reliability_decay:            20;&lt;br /&gt;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);&lt;br /&gt;
        non_refittable_cargo_classes: bitmask();&lt;br /&gt;
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling&lt;br /&gt;
        // It&#039;s an intercity train, loading is relatively slow:&lt;br /&gt;
        loading_speed:                6; &lt;br /&gt;
        cost_factor:                  45;&lt;br /&gt;
        running_cost_factor:          100; // Changed by callback&lt;br /&gt;
        sprite_id:                    SPRITE_ID_NEW_TRAIN;&lt;br /&gt;
        speed:                        141 km/h; // actually 140, but there are rounding errors&lt;br /&gt;
        misc_flags:                   bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);&lt;br /&gt;
        refit_cost:                   0; //refit costs don&#039;t apply to subcargo display &lt;br /&gt;
        // callback flags are not set manually&lt;br /&gt;
        track_type:                   ELRL; // from rail type table&lt;br /&gt;
        ai_special_flag:              AI_FLAG_PASSENGER;&lt;br /&gt;
        power:                        1260 kW; // Changed by CB&lt;br /&gt;
        running_cost_base:            RUNNING_COST_ELECTRIC;&lt;br /&gt;
        dual_headed:                  0;&lt;br /&gt;
        cargo_capacity:               36; // per part, changed by callback&lt;br /&gt;
        weight:                       144 ton; // Total, changed by callback&lt;br /&gt;
        ai_engine_rank:               0; // not intended to be used by the ai&lt;br /&gt;
        engine_class:                 ENGINE_CLASS_ELECTRIC;&lt;br /&gt;
        extra_power_per_wagon:        0 kW;&lt;br /&gt;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:&lt;br /&gt;
        tractive_effort_coefficient:  0.3 / 3; // changed by callback&lt;br /&gt;
        air_drag_coefficient:         0.06;&lt;br /&gt;
        shorten_vehicle:              SHORTEN_TO_8_8;&lt;br /&gt;
        // Overridden by callback to disable for non-powered wagons:&lt;br /&gt;
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);&lt;br /&gt;
        extra_weight_per_wagon:       0 ton;&lt;br /&gt;
        bitmask_vehicle_info:         0;&lt;br /&gt;
    }&lt;br /&gt;
    /* Define graphics and callbacks&lt;br /&gt;
     * Setting all callbacks is not needed, only define what is used */&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:                      sw_icm_graphics;&lt;br /&gt;
        purchase:                     set_icm_purchase;&lt;br /&gt;
        cargo_subtype_text:           sw_icm_cargo_subtype_text;&lt;br /&gt;
        additional_text:              return string(STR_ICM_ADDITIONAL_TEXT);&lt;br /&gt;
        colour_mapping:               sw_icm_colour_mapping;&lt;br /&gt;
        start_stop:                   sw_icm_start_stop;&lt;br /&gt;
        articulated_part:             sw_icm_articulated_part;&lt;br /&gt;
        can_attach_wagon:             sw_icm_can_attach_wagon;&lt;br /&gt;
        running_cost_factor:          return (cargo_subtype == 1) ? 150 : 100;&lt;br /&gt;
        /* Capacity is per part */&lt;br /&gt;
        cargo_capacity:               return (cargo_subtype == 0) &amp;amp;&amp;amp; ((position_in_consist % 4) == 2) ? 0 : 36;&lt;br /&gt;
        /* In the purchase menu, we want to show the capacity for the three-part version,&lt;br /&gt;
         * i.e. divide the capacity of three cars across four */&lt;br /&gt;
        purchase_cargo_capacity:      return 36 * 3 / 4;&lt;br /&gt;
        /* Only the front vehicle has a visual effect */&lt;br /&gt;
        visual_effect_and_powered:    return (position_in_consist % 4 == 0) ?&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER) :&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);&lt;br /&gt;
        length:                       sw_icm_shorten_vehicle;&lt;br /&gt;
        /* Only the front vehicle has power */&lt;br /&gt;
        power:                        sw_icm_power;&lt;br /&gt;
        //purchase_power:               return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
        /* Only the front vehicle has weight */&lt;br /&gt;
        weight:                       sw_icm_weight;&lt;br /&gt;
        /* Only the front vehicle has TE */&lt;br /&gt;
        tractive_effort_coefficient:  sw_icm_te;&lt;br /&gt;
        /* Only 1/3 of the weight is on the driving weels. */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The complete language file ===&lt;br /&gt;
english.lng now contains this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example small&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
&lt;br /&gt;
STR_GRF_NAME                 :NML Example NewGRF: Train&lt;br /&gt;
STR_GRF_DESC                 :{ORANGE}NML Example NewGRF: Train{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}Purno, {BLACK}coding by {SILVER}DJNekkid.{}{BLACK}This NewGRF defines a Dutch EMU, the ICM &#039;Koploper&#039;.&lt;br /&gt;
&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_NAME :Colour scheme&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_DESC :Select the type of colour scheme to use&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_1CC  :One company colour&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_2CC  :Two company colours&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_REAL :Real-world colours&lt;br /&gt;
&lt;br /&gt;
STR_ICM_NAME                 :ICM &#039;Koploper&#039; (Electric)&lt;br /&gt;
STR_ICM_ADDITIONAL_TEXT      :Choose between 3- and 4-part EMU via refit{}Stated values are for the 3-part variant, the 4-part version has 33% more capacity and 50% more power and running cost.&lt;br /&gt;
STR_ICM_SUBTYPE_3_PART       : (3 parts)&lt;br /&gt;
STR_ICM_SUBTYPE_4_PART       : (4 parts)&lt;br /&gt;
STR_ICM_CANNOT_START         :... train too long (max. 4 coupled EMUs).&lt;br /&gt;
STR_ICM_CANNOT_ATTACH_OTHER  :... only other ICMs can be attached to ICM.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now our train is really completed and that makes this the end of the train example.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Parameters|Object}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_four_part_refit&amp;diff=8341</id>
		<title>NMLTutorial/Train four part refit</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_four_part_refit&amp;diff=8341"/>
		<updated>2012-05-03T16:53:45Z</updated>

		<summary type="html">&lt;p&gt;FooBar: use length instead of shorten_vehicle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the [http://dev.openttdcoop.org/projects/nml/repository/show/examples NML source]. The code for this was originally written in NFO by DJNekkid for the 2cc Trainset and rewritten in NML by Hirundo. The graphics used in the example are by Purno. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues the [[NMLTutorial/Train three part articulated|third part]] of the train example. The three part EMU will be made refittable to a four part EMU.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What&#039;s going to happen ==&lt;br /&gt;
A lot of things need to be added to make this train refittable between three and four parts.&lt;br /&gt;
&lt;br /&gt;
The method used to do this is actually the other way round than the user will think from the behaviour ingame. The train will be changed to a four part EMU. For the (default) three part refit one of these four parts will be hidden. A lot of switches will be used to make the train look right, make it have the correct capacity, power, weight, running costs and tractive effort.&lt;br /&gt;
&lt;br /&gt;
There are some drawbacks to this method. There&#039;s no way to charge the user for puchasing the extra vehicle part. Also autoreplacing will be difficult, as there&#039;s now way for the user to select which vehicle length they want. For that reason the author of this tutorial thinks making two different vehicles and having both available from the purchase menu is a better solution, but this method is a good illustration for some of the more advanced features of NML. It&#039;s up to you to decide which implementation you think is best for your vehicles.&lt;br /&gt;
&lt;br /&gt;
What we&#039;ll be doing:&lt;br /&gt;
* Add the refit option;&lt;br /&gt;
* Make the graphics work;&lt;br /&gt;
* Add callbacks to supply the correct vehicle properties;&lt;br /&gt;
* Make the purchase menu display the correct values.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refit option ==&lt;br /&gt;
The refit option will be added by means of the &amp;quot;cargo subtype&amp;quot;. This allows to split each cargo into multiple entities which can be assigned different properties by means of other callbacks.&lt;br /&gt;
&lt;br /&gt;
The first step towards this is defining names for these separate entries using the &amp;lt;code&amp;gt;cargo_subtype_text&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback]. This callback requires the use of a switch, so reference a switch from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        cargo_subtype_text:           sw_icm_cargo_subtype_text;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch itself will use the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. This variable starts at 0 and will be increased by 1 until the callback returns &amp;lt;code&amp;gt;CB_RESULT_NO_MORE_ARTICULATED_PARTS&amp;lt;/code&amp;gt;. Return strings to use as cargo subtype. Each returned string will be a separate cargo subtype:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_cargo_subtype_text, cargo_subtype) {&lt;br /&gt;
    0: return string(STR_ICM_SUBTYPE_3_PART);&lt;br /&gt;
    1: return string(STR_ICM_SUBTYPE_4_PART);&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This adds two cargo subtypes. Also add these strings to the language file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
STR_ICM_SUBTYPE_3_PART       : (3 parts)&lt;br /&gt;
STR_ICM_SUBTYPE_4_PART       : (4 parts)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
The graphics defined previously were for a three part vehicle. Now we have to make this into a four part vehicle and hide one wagon for the three part refit.&lt;br /&gt;
&lt;br /&gt;
=== Four part articulated vehicle ===&lt;br /&gt;
In order to make the vehicle four parts, the articulated vehicle callback switch needs to be changed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add three articulated parts, for a total of four */&lt;br /&gt;
    1 .. 3: return item_icm;&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is done by changing the value range from &amp;lt;code&amp;gt;1 .. 2&amp;lt;/code&amp;gt; into &amp;lt;code&amp;gt;1 .. 3&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Start/stop callback ===&lt;br /&gt;
The start/stop callback checking the vehicle length needs to be changed as well. If we still want a maximum of four EMUs, the maximum length will now be 4 * 4 instead of 4 * 3. This means changing the switch for this callback:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12-16 cars) */&lt;br /&gt;
    1 .. 16: return CB_RESULT_NO_TEXT;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is done by changing the value range from &amp;lt;code&amp;gt;1 .. 12&amp;lt;/code&amp;gt; into &amp;lt;code&amp;gt;1 .. 16&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Graphics ===&lt;br /&gt;
Now that the vehicle is four parts, the default graphics switch needs to be changed as well to allow for two middle parts instead of one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      set_icm_front_lighted;&lt;br /&gt;
    3:      set_icm_rear_lighted;&lt;br /&gt;
    sw_icm_graphics_middle;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of modulo 3 we&#039;re now taking modulo 4. And the value for the rear vehicle part was changed from 2 to 3. For the middle parts, we also need to hide the one of the wagons for the three part EMU. Therefore we can&#039;t directly reference the spriteset but need an extra intermediate switch block.&lt;br /&gt;
&lt;br /&gt;
The extra switch block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_middle, ((position_in_consist % 4) == 2) &amp;amp;&amp;amp; (cargo_subtype == 0)) {&lt;br /&gt;
    1: set_icm_invisible;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even an expression this advanced can be used for switch block decision. Here we again check the position of the vehicle part, but also which cargo subtype is used for this vehicle. If it is the three part EMU (cargo subtype 0) AND it is the third vehicle part (position 2 counting from 0), we hide this vehicle part by displaying no graphics for it. In all other cases we display the regular middle part.&lt;br /&gt;
&lt;br /&gt;
=== Vehicle length ===&lt;br /&gt;
If you were to encode the result so far as a NewGRF, you end up with a three part train that has a big gap between the second and last part. This is because it&#039;s essentially still a four part vehicle, just with no graphics for the third part. This can be solved by changing the length of the two middle parts. If we make the second part (7/8) long and the third part (1/8), both together are a full wagon length, completely hiding the invisible third part.&lt;br /&gt;
&lt;br /&gt;
This is done by means of the &amp;lt;code&amp;gt;length&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback], referencing a switch block as we first need to differentiate between the two cargo subtypes and then by the position in consist. Reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        length:              sw_icm_shorten_vehicle;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we get the two switch blocks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* --- Shorten vehicle callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_3_part_vehicle, position_in_consist % 4) {&lt;br /&gt;
    /* In the three part version, shorten the 2nd vehicle to 7/8 and the 3rd to 1/8&lt;br /&gt;
     * The rear (1/8) part is then made invisisble */&lt;br /&gt;
    1: return 7;&lt;br /&gt;
    2: return 1;&lt;br /&gt;
    return 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_vehicle, cargo_subtype) {&lt;br /&gt;
    0: sw_icm_shorten_3_part_vehicle;&lt;br /&gt;
    return 8; // 4-part vehicle needs no shortening&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The second of these switch blocks (called first from the graphics block) differentiates between the two cargo subtypes. For subtype 0 (three part vehicle) we need to do the shortenings and reference the first switch block. For the four part vehicle we need no shortening, so directly return to &amp;quot;shorten&amp;quot; to full length.&lt;br /&gt;
&lt;br /&gt;
The first switch again makes a decision based on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] we&#039;ve seen several times now. As said, the second part will be shortened to (7/8), the third part to (1/8) and the front and back part are kept full length (8/8).&lt;br /&gt;
&lt;br /&gt;
Now the vehicle looks good in both refits.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vehicle properties ==&lt;br /&gt;
Both refits still have identical properties. Surely the four part EMU has a higher capacity. We&#039;ll also change the running costs, power, weight and tractive effort depending on the refit chosen. This is all done by callbacks. You can find the available vehicle callbacks [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks here], with the second table especially on callbacks that change certain properties.&lt;br /&gt;
&lt;br /&gt;
=== Running cost factor ===&lt;br /&gt;
You can easily imagine that the longer vehicle will be more expensive to run. The three part has a running cost factor of 100, the four part will get a factor of 150. This requires adding the &amp;lt;code&amp;gt;running_cost_factor&amp;lt;/code&amp;gt; callback to the graphics block. From there we can link to a switch block and base the decision on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. A different method as shown below is not to use a switch block but to make the decision directly from the graphics block using a conditional assignment. We&#039;ve used a conditional assignment [[Train_single_engine#Templates|before]] in one of the template blocks.&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        running_cost_factor:          return (cargo_subtype == 1) ? 150 : 100;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; is 1 (the four part vehicle), a running cost factor of 150 is used. Otherwise, a factor of 100 is used. If you&#039;d rather used a switch block then that&#039;s up to you. Just reference one from the graphics block instead of the conditional assignment and use the switch block to make the decision based on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
=== Cargo capacity ===&lt;br /&gt;
The cargo capacity is 36 passengers per unit. Now the three part EMU will have a capacity that is too high, because it technically is a four part EMU with one part hidden. We need to give this hidden part 0 capacity.&lt;br /&gt;
&lt;br /&gt;
This is done by the &amp;lt;code&amp;gt;cargo_capacity&amp;lt;/code&amp;gt; callback. If the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; is 0 and the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; is the third part, we give it 0 capacity. Else it will get 36 capacity. Also this can be done directly from the graphics block, using a slightly more advanced conditional assignment. Of course you could again have used a switch block here, but there&#039;s no need for that in this case.&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
cargo_capacity:               return (cargo_subtype == 0) &amp;amp;&amp;amp; ((position_in_consist % 4) == 2) ? 0 : 36;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Power ===&lt;br /&gt;
The power of the four part vehicle will be higher. Let&#039;s use a switch block this time. Of course a conditional assignment could be used here, but compare this example with the running cost factor yourself. The callback used here is called &amp;lt;code&amp;gt;power&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        power:                        sw_icm_power;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself will again make a decision based on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable. The callback must return the vehicle power in horsepower (imperial) and this must be an integer value. Because we know the power in kW, a little calculation is needed which NML can do for you. Returning the integer is done by the &amp;lt;code&amp;gt;int()&amp;lt;/code&amp;gt; function that turns a (decimal) number into an integer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_power, cargo_subtype) {&lt;br /&gt;
    0: return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
    return int(1890 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Weight ===&lt;br /&gt;
Of course you could have done the calculation yourself and put the rounded values in the switch block. That we&#039;ll do for the weight of the vehicle. The callback used here is called &amp;lt;code&amp;gt;weight&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Again, reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
weight:                       sw_icm_weight;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself will again make a decision based on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable. The weight here must be specified in tons:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_weight, cargo_subtype) {&lt;br /&gt;
    0: return 144; //ton, 3 part train&lt;br /&gt;
    return 192; //ton, 4 part train&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tractive effort coefficient===&lt;br /&gt;
The last property to sort out is the tractive effort. The callback used here is called &amp;lt;code&amp;gt;tractive_effort_coefficient&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Again, reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        tractive_effort_coefficient:  sw_icm_te;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the switch block we&#039;ll actually calculate the tractive effort coefficient:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_te, cargo_subtype) {&lt;br /&gt;
    /* Base TE coefficient = 0.3&lt;br /&gt;
     * 3 parts: 4/12 of weight on driving wheels&lt;br /&gt;
     * 4 parts: 6/16 of weight on driving wheels */&lt;br /&gt;
    0: return int(0.3 * 255 / 3);&lt;br /&gt;
    return int(0.3 * 255 * 3 / 8);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;The technical background of the tractive effort coefficient is that it must be supplied as value between 0 and 255, with 255 equal to 100%. The tractive effort coefficient itself is calculated by multiplying the friction coefficient (see [http://en.wikipedia.org/wiki/Rail_adhesion Wikipedia] for it&#039;s meaning) with the percentage of weight that is on driven wheels. I this case we use a friction of 30%. In real life the three part vehicle has 12 axles of which 4 powered. The four part vehicle has 16 axles of which 6 powered. Assuming an equal distribution of weight along the length of the vehicle, the three part vehicle has 33.3% of it&#039;s weight on powered wheels. The four part vehicle has 37.5% of it&#039;s weight on powered wheels. Multiply both by the friction coefficient and the factor of 255 and you have the tractive effort coefficient.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you don&#039;t provide a tractive effort coefficient, the game will assume a friction coefficient of 0.3 and all axles powered. A tractive effort coefficient of 100% you&#039;ll only get with 100% friction and and all axles powered. This is unrealistic for railroads but can be used for maglev when there actually is no contact between vehicle and guideway.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purchase menu ==&lt;br /&gt;
With all these callbacks we&#039;ve sort of broken the display of properties in the purchase menu. This is because the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] is not available in the purchase menu and &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable is always 0 in the purchase menu. The latter can be to our advantage if we want to display the properties of the shorter refit, but the other needs some fixing.&lt;br /&gt;
&lt;br /&gt;
=== Running cost factor ===&lt;br /&gt;
This callback was only based on &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt;, so no fixing needed here.&lt;br /&gt;
&lt;br /&gt;
=== Cargo capacity ===&lt;br /&gt;
The capacity used both variables, so some fixing is in order here. We want to display 36*3 as capacity. Because capacity is defined per unit and our vehicle is technically four units, we need to divide this over four units: 36*3/4. Add the &amp;lt;code&amp;gt;purchase_cargo_capacity&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback] to the graphics block and return this value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        purchase_cargo_capacity:      return 36 * 3 / 4;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Power, weight and tractive effort coefficient ===&lt;br /&gt;
Luckily, these are also only based on the cargo subtype variable, so no fixing needed. If you wanted a different value to be displayed in the purchase menu, you&#039;d use the &amp;lt;code&amp;gt;purchase_power&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;purchase_weight&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;purchase_tractive_effort_coefficient&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callbacks] to do this. And if you want to know, the running cost factor would logically use the &amp;lt;code&amp;gt;purchase_running_cost_factor&amp;lt;/code&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
=== Additional text ===&lt;br /&gt;
We want to inform the user that this train has an option to refit it into a four part version and that the properties shown are for the three part version. For this we&#039;ll use the &amp;lt;code&amp;gt;additional_text&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback] which we also used in the tram example. It can directly return a string from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        additional_text:              return string(STR_ICM_ADDITIONAL_TEXT);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also don&#039;t forget to add this string to the language file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
STR_ICM_ADDITIONAL_TEXT      :Choose between 3- and 4-part EMU via refit{}Stated values are for the 3-part variant, the 4-part version has 33% more capacity and 50% more power and running cost.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This means our vehicle now works like it should with the two refits. Encode it into a NewGRF if you like.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Total code so far ==&lt;br /&gt;
When put in the correct order, this should now encode as a working NewGRF. The total code so far:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
/* Define grf */&lt;br /&gt;
grf {&lt;br /&gt;
    grfid: &amp;quot;NML\00&amp;quot;;&lt;br /&gt;
    /* GRF name and description strings are defined in the lang files */&lt;br /&gt;
    name: string(STR_GRF_NAME);&lt;br /&gt;
    desc: string(STR_GRF_DESC);&lt;br /&gt;
    /* This is the first version, start numbering at 0. */&lt;br /&gt;
    version: 0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define a rail type table,&lt;br /&gt;
 * this allows referring to railtypes&lt;br /&gt;
 * irrespective of the grfs loaded.&lt;br /&gt;
 */&lt;br /&gt;
railtypetable {&lt;br /&gt;
    ELRL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Basic template for 4 vehicle views */&lt;br /&gt;
template tmpl_vehicle_basic(x, y) {&lt;br /&gt;
    // arguments x, y: coordinates of top-left corner of first sprite&lt;br /&gt;
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xrel yrel&lt;br /&gt;
    [x +  9, y, 22, 20, -14, -12]&lt;br /&gt;
    [x + 32, y, 32, 16, -16, -12]&lt;br /&gt;
    [x + 65, y, 22, 20,  -6, -12]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with only 4 views (symmetric) */&lt;br /&gt;
template tmpl_vehicle_4_views(num) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    tmpl_vehicle_basic(1, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with 8 views (non-symmetric) */&lt;br /&gt;
template tmpl_vehicle_8_views(num, reversed) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    // argument reversed: Reverse visible orientation of vehicle, if set to 1&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a single vehicle sprite */&lt;br /&gt;
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {&lt;br /&gt;
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the spritesets, these allow referring to these sprites later on */&lt;br /&gt;
spriteset (set_icm_front_lighted, &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(0, 0) }&lt;br /&gt;
spriteset (set_icm_rear_lighted,  &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(1, 1) }&lt;br /&gt;
spriteset (set_icm_front,         &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(2, 0) }&lt;br /&gt;
spriteset (set_icm_rear,          &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(3, 1) }&lt;br /&gt;
spriteset (set_icm_middle,        &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_4_views(4)    }&lt;br /&gt;
spriteset (set_icm_purchase,      &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(5, 53, 14, -25, -10) }&lt;br /&gt;
spriteset (set_icm_invisible,     &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(6,  1,  1,   0,   0) }&lt;br /&gt;
&lt;br /&gt;
/* --- Graphics callback  --- */&lt;br /&gt;
&lt;br /&gt;
/* In the 3-part version, the 3rd car is invisible */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_middle, ((position_in_consist % 4) == 2) &amp;amp;&amp;amp; (cargo_subtype == 0)) {&lt;br /&gt;
    1: set_icm_invisible;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      set_icm_front_lighted;&lt;br /&gt;
    3:      set_icm_rear_lighted;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Cargo subtype text --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_cargo_subtype_text, cargo_subtype) {&lt;br /&gt;
    0: return string(STR_ICM_SUBTYPE_3_PART);&lt;br /&gt;
    1: return string(STR_ICM_SUBTYPE_4_PART);&lt;br /&gt;
    return CB_RESULT_NO_TEXT;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Articulated part callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add three articulated parts, for a total of four */&lt;br /&gt;
    1 .. 3: return item_icm;&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Start/stop callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12-16 cars) */&lt;br /&gt;
    1 .. 16: return CB_RESULT_NO_TEXT;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Wagon attach callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_can_attach_wagon, vehicle_type_id) {&lt;br /&gt;
    /* SELF refers to the wagon here, check that it&#039;s an ICM */&lt;br /&gt;
    item_icm: return CB_RESULT_ATTACH_ALLOW;&lt;br /&gt;
    return string(STR_ICM_CANNOT_ATTACH_OTHER);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Shorten vehicle callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_3_part_vehicle, position_in_consist % 4) {&lt;br /&gt;
    /* In the three part version, shorten the 2nd vehicle to 7/8 and the 3rd to 1/8&lt;br /&gt;
     * The rear (1/8) part is then made invisisble */&lt;br /&gt;
    1: return 7;&lt;br /&gt;
    2: return 1;&lt;br /&gt;
    return 8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_vehicle, cargo_subtype) {&lt;br /&gt;
    0: sw_icm_shorten_3_part_vehicle;&lt;br /&gt;
    return 8; // 4-part vehicle needs no shortening&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Power, weight and TE are all applied to the front vehicle only */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_power, cargo_subtype) {&lt;br /&gt;
    0: return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
    return int(1890 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_weight, cargo_subtype) {&lt;br /&gt;
    0: return 144; //ton, 3 part train&lt;br /&gt;
    return 192; //ton, 4 part train&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_te, cargo_subtype) {&lt;br /&gt;
    /* Base TE coefficient = 0.3&lt;br /&gt;
     * 3 parts: 4/12 of weight on driving wheels&lt;br /&gt;
     * 4 parts: 6/16 of weight on driving wheels */&lt;br /&gt;
    0: return int(0.3 * 255 / 3);&lt;br /&gt;
    return int(0.3 * 255 * 3 / 8);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the actual train */&lt;br /&gt;
item(FEAT_TRAINS, item_icm) {&lt;br /&gt;
    /* Define properties first, make sure to set all of them */&lt;br /&gt;
    property {&lt;br /&gt;
        name:                         string(STR_ICM_NAME);&lt;br /&gt;
        // not available in toyland:&lt;br /&gt;
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); &lt;br /&gt;
        introduction_date:            date(1983, 1, 1);&lt;br /&gt;
        model_life:                   VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        vehicle_life:                 30;&lt;br /&gt;
        reliability_decay:            20;&lt;br /&gt;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);&lt;br /&gt;
        non_refittable_cargo_classes: bitmask();&lt;br /&gt;
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling&lt;br /&gt;
        // It&#039;s an intercity train, loading is relatively slow:&lt;br /&gt;
        loading_speed:                6; &lt;br /&gt;
        cost_factor:                  45;&lt;br /&gt;
        running_cost_factor:          100; // Changed by callback&lt;br /&gt;
        sprite_id:                    SPRITE_ID_NEW_TRAIN;&lt;br /&gt;
        speed:                        141 km/h; // actually 140, but there are rounding errors&lt;br /&gt;
        misc_flags:                   bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);&lt;br /&gt;
        refit_cost:                   0; //refit costs don&#039;t apply to subcargo display &lt;br /&gt;
        // callback flags are not set manually&lt;br /&gt;
        track_type:                   ELRL; // from rail type table&lt;br /&gt;
        ai_special_flag:              AI_FLAG_PASSENGER;&lt;br /&gt;
        power:                        1260 kW; // Changed by CB&lt;br /&gt;
        running_cost_base:            RUNNING_COST_ELECTRIC;&lt;br /&gt;
        dual_headed:                  0;&lt;br /&gt;
        cargo_capacity:               36; // per part, changed by callback&lt;br /&gt;
        weight:                       144 ton; // Total, changed by callback&lt;br /&gt;
        ai_engine_rank:               0; // not intended to be used by the ai&lt;br /&gt;
        engine_class:                 ENGINE_CLASS_ELECTRIC;&lt;br /&gt;
        extra_power_per_wagon:        0 kW;&lt;br /&gt;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:&lt;br /&gt;
        tractive_effort_coefficient:  0.3 / 3; // changed by callback&lt;br /&gt;
        air_drag_coefficient:         0.06;&lt;br /&gt;
        shorten_vehicle:              SHORTEN_TO_8_8;&lt;br /&gt;
        // Overridden by callback to disable for non-powered wagons:&lt;br /&gt;
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);&lt;br /&gt;
        extra_weight_per_wagon:       0 ton;&lt;br /&gt;
        bitmask_vehicle_info:         0;&lt;br /&gt;
    }&lt;br /&gt;
    /* Define graphics and callbacks&lt;br /&gt;
     * Setting all callbacks is not needed, only define what is used */&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:                      sw_icm_graphics;&lt;br /&gt;
        purchase:                     set_icm_purchase;&lt;br /&gt;
        cargo_subtype_text:           sw_icm_cargo_subtype_text;&lt;br /&gt;
        additional_text:              return string(STR_ICM_ADDITIONAL_TEXT);&lt;br /&gt;
        start_stop:                   sw_icm_start_stop;&lt;br /&gt;
        articulated_part:             sw_icm_articulated_part;&lt;br /&gt;
        can_attach_wagon:             sw_icm_can_attach_wagon;&lt;br /&gt;
        running_cost_factor:          return (cargo_subtype == 1) ? 150 : 100;&lt;br /&gt;
        /* Capacity is per part */&lt;br /&gt;
        cargo_capacity:               return (cargo_subtype == 0) &amp;amp;&amp;amp; ((position_in_consist % 4) == 2) ? 0 : 36;&lt;br /&gt;
        /* In the purchase menu, we want to show the capacity for the three-part version,&lt;br /&gt;
         * i.e. divide the capacity of three cars across four */&lt;br /&gt;
        purchase_cargo_capacity:      return 36 * 3 / 4;&lt;br /&gt;
        length:                       sw_icm_shorten_vehicle;&lt;br /&gt;
        /* Only the front vehicle has power */&lt;br /&gt;
        power:                        sw_icm_power;&lt;br /&gt;
        /* Only the front vehicle has weight */&lt;br /&gt;
        weight:                       sw_icm_weight;&lt;br /&gt;
        /* Only the front vehicle has TE */&lt;br /&gt;
        tractive_effort_coefficient:  sw_icm_te;&lt;br /&gt;
        /* Only 1/3 of the weight is on the driving weels. */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language file so far ===&lt;br /&gt;
english.lng now contains this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
&lt;br /&gt;
STR_GRF_NAME                 :NML Example NewGRF: Train&lt;br /&gt;
STR_GRF_DESC                 :{ORANGE}NML Example NewGRF: Train{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}Purno, {BLACK}coding by {SILVER}DJNekkid.{}{BLACK}This NewGRF defines a Dutch EMU, the ICM &#039;Koploper&#039;.&lt;br /&gt;
&lt;br /&gt;
STR_ICM_NAME                 :ICM &#039;Koploper&#039; (Electric)&lt;br /&gt;
STR_ICM_ADDITIONAL_TEXT      :Choose between 3- and 4-part EMU via refit{}Stated values are for the 3-part variant, the 4-part version has 33% more capacity and 50% more power and running cost.&lt;br /&gt;
STR_ICM_SUBTYPE_3_PART       : (3 parts)&lt;br /&gt;
STR_ICM_SUBTYPE_4_PART       : (4 parts)&lt;br /&gt;
STR_ICM_CANNOT_START         :... train too long (max. 4 coupled EMUs).&lt;br /&gt;
STR_ICM_CANNOT_ATTACH_OTHER  :... only other ICMs can be attached to ICM.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you like, this train is done. If you like to continue, you can learn about GRF parameters and then we&#039;ll add a parameter setting to display this train in either 1cc, 2cc or real life colours.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Train three part articulated|Parameters}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Tram_purchase_menu&amp;diff=8340</id>
		<title>NMLTutorial/Tram purchase menu</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Tram_purchase_menu&amp;diff=8340"/>
		<updated>2012-05-03T16:48:24Z</updated>

		<summary type="html">&lt;p&gt;FooBar: use length instead of shorten_vehicle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is the HTM 4001 from the [http://dev.openttdcoop.org/projects/dutchtramset/repository Dutch Tram Set]. The original code and graphics for this are by FooBar. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This continues and concludes the [[NMLTutorial/Tram graphics|third part]] of the tram example. We&#039;ll look into some things dealing with the purchase menu.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purchase menu text ==&lt;br /&gt;
There is a callback that allows adding text to the purchase menu. In the Dutch Tram Set this is used to give you some information on how the vehicles were/are used in real life. For the tram in this example, we already defined such a text in the language files. Let&#039;s add it to the purchase menu.&lt;br /&gt;
&lt;br /&gt;
The callback needed for this you must again [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks look up] in the NML Documentation and is named &amp;lt;code&amp;gt;additional_text&amp;lt;/code&amp;gt;. And it&#039;s an easy one at that, because we can just return the string that must be displayed straight from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
    graphics {&lt;br /&gt;
        additional_text:         return string(STR_DESC_HTM_4001); //Additional text shown in purchase list&lt;br /&gt;
        articulated_part:        switch_articulated_htm_4001;&lt;br /&gt;
        length:                  switch_length_htm_4001;&lt;br /&gt;
        cargo_capacity:          switch_capacity_htm_4001;&lt;br /&gt;
        default:                 switch_spriteset_htm_4001;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Callback done. Easy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purchase menu sprite ==&lt;br /&gt;
You may remember a separate sprite and template for the purchase menu. In order to use this, you need a spriteset block and reference this from the graphics block. The spriteset is again pretty straightforward:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
spriteset(spriteset_purchase_htm_4001, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_purchase(0, 140)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Referencing that from the graphics block isn&#039;t too difficult either, as you&#039;ve done that before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
    graphics {&lt;br /&gt;
        purchase:                spriteset_purchase_htm_4001; //Purchase menu sprite&lt;br /&gt;
        additional_text:         return string(STR_DESC_HTM_4001); //Additional text shown in purchase list&lt;br /&gt;
        articulated_part:        switch_articulated_htm_4001;&lt;br /&gt;
        length:                  switch_length_htm_4001;&lt;br /&gt;
        cargo_capacity:          switch_capacity_htm_4001;&lt;br /&gt;
        default:                 switch_spriteset_htm_4001;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The identifiers are of course the same in the graphics block and in the spriteset block. The spriteset block must be defined before the item block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fixing the purchase menu capacity display ==&lt;br /&gt;
Using the cargo capacity callback comes with a side-effect: the capacity display in the purchase menu is broken. The reason for this is that the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; variable is [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables not available] in the purchase menu. As a result, the game can&#039;t calculate the capacity for each vehicle part in the purchase menu, you&#039;ll get some unknown behaviour and as a result an incorrect capacity in the purchase menu.&lt;br /&gt;
&lt;br /&gt;
The solution to this is to tell the game not to use the capacity from the callback in the purchase menu, but instead to use the capacity from the capacity property (form the property block) in the purchase menu.&lt;br /&gt;
&lt;br /&gt;
The way this solution works is to define a separate cargo capacity callback for the purchase menu, but instead of returning a capacity value linking this callback directly to the purchase menu spriteset. Sounds a bit of a trick solution, and it is. The result is that the cargo capacity callback for the purchase menu will fail and that the cargo capacity property is used instead. And above all it&#039;s not a hack, but completely legal NML code.&lt;br /&gt;
&lt;br /&gt;
The callback name for the graphics block to do this is called &amp;lt;code&amp;gt;purchase_cargo_capacity&amp;lt;/code&amp;gt; and can be found in the [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks usual place]. Your final graphics block will now look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
    graphics {&lt;br /&gt;
        purchase:                spriteset_purchase_htm_4001; //Purchase menu sprite&lt;br /&gt;
        additional_text:         return string(STR_DESC_HTM_4001); //Additional text shown in purchase list&lt;br /&gt;
        articulated_part:        switch_articulated_htm_4001;&lt;br /&gt;
        length:                  switch_length_htm_4001;&lt;br /&gt;
        cargo_capacity:          switch_capacity_htm_4001;&lt;br /&gt;
        purchase_cargo_capacity: spriteset_purchase_htm_4001; //&amp;lt;-- linked to the purchase menu spriteset&lt;br /&gt;
        default:                 switch_spriteset_htm_4001;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cargo capacity property will now be applied to each part of the vehicle for display in the purchase menu. In this case, three times the cargo capacity property will be displayed as total capacity in the purchase menu. And this completes the tram example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The complete code ==&lt;br /&gt;
The complete NML code for the tram vehicle:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
// define the newgrf&lt;br /&gt;
grf {&lt;br /&gt;
	grfid:	&amp;quot;\FB\FB\01\02&amp;quot;;&lt;br /&gt;
	name:	string(STR_GRF_NAME);&lt;br /&gt;
	desc:	string(STR_GRF_DESCRIPTION);&lt;br /&gt;
	version:		REPO_REVISION;&lt;br /&gt;
	min_compatible_version:	87;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
////////////////////////&lt;br /&gt;
//Purchase menu sprite//&lt;br /&gt;
////////////////////////&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_purchase_htm_4001, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_purchase(0, 140)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////&lt;br /&gt;
//Vehicle sprites//&lt;br /&gt;
///////////////////&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_real_htm_4001, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_28(0, 20)&lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_real_htm_4001_1, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_24(0, 60)&lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_real_htm_4001_2, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_28(0, 100)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_spriteset_htm_4001, position_in_consist ) {&lt;br /&gt;
    1: spriteset_real_htm_4001_1;&lt;br /&gt;
    2: spriteset_real_htm_4001_2;&lt;br /&gt;
    spriteset_real_htm_4001; //default&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////&lt;br /&gt;
//vehicle callbacks//&lt;br /&gt;
/////////////////////&lt;br /&gt;
&lt;br /&gt;
//set number of articulated parts&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_articulated_htm_4001, extra_callback_info1) {&lt;br /&gt;
    1..2: return item_tram_htm_4001; //use same vehicle for all parts&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//set length of each part&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_length_htm_4001, position_in_consist) {&lt;br /&gt;
    1: return 6;&lt;br /&gt;
    return 7;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//set capacity of each part&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_capacity_htm_4001, position_in_consist ) {&lt;br /&gt;
    1: return 26;&lt;br /&gt;
    return 38; //default&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////&lt;br /&gt;
//vehicle properties//&lt;br /&gt;
//////////////////////&lt;br /&gt;
&lt;br /&gt;
item (FEAT_ROADVEHS, item_tram_htm_4001) {&lt;br /&gt;
    property {&lt;br /&gt;
        name:                        string(STR_NAME_HTM_4001);&lt;br /&gt;
        introduction_date:           date(2006,1,1);&lt;br /&gt;
        model_life:                  VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        retire_early:                0;&lt;br /&gt;
        vehicle_life:                25;&lt;br /&gt;
        loading_speed:               25;&lt;br /&gt;
        cost_factor:                 224;&lt;br /&gt;
        running_cost_factor:         112;&lt;br /&gt;
        speed:                       81 km/h;&lt;br /&gt;
        power:                       966 hp;&lt;br /&gt;
        weight:                      58 ton;&lt;br /&gt;
        cargo_capacity:              (38*2+26)/3;&lt;br /&gt;
        tractive_effort_coefficient: 0.5;&lt;br /&gt;
        air_drag_coefficient:        0;&lt;br /&gt;
        //sound_effect:              no sound&lt;br /&gt;
        //visual_effect:             use default (none)&lt;br /&gt;
        &lt;br /&gt;
        //callback_flags:            no need to set this&lt;br /&gt;
        reliability_decay:           20;&lt;br /&gt;
        climates_available:          ALL_CLIMATES;&lt;br /&gt;
        refittable_cargo_classes:    bitmask(CC_PASSENGERS);&lt;br /&gt;
        sprite_id:                   SPRITE_ID_NEW_ROADVEH; //use custom sprites&lt;br /&gt;
        misc_flags:                  bitmask(ROADVEH_FLAG_TRAM); //make this a tram&lt;br /&gt;
        refit_cost:                  0; //refits are free&lt;br /&gt;
        running_cost_base:           RUNNING_COST_ROADVEH;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    graphics {&lt;br /&gt;
        purchase:                spriteset_purchase_htm_4001; //Purchase menu sprite&lt;br /&gt;
        additional_text:         return string(STR_DESC_HTM_4001); //Additional text shown in purchase list&lt;br /&gt;
        articulated_part:        switch_articulated_htm_4001;&lt;br /&gt;
        length:                  switch_length_htm_4001;&lt;br /&gt;
        cargo_capacity:          switch_capacity_htm_4001;&lt;br /&gt;
        purchase_cargo_capacity: spriteset_purchase_htm_4001;&lt;br /&gt;
        default:                 switch_spriteset_htm_4001;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
That concludes the articulated tram example. The next part of this tutorial will a train example with some fancy features.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Tram graphics|Train}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Tram_graphics&amp;diff=8339</id>
		<title>NMLTutorial/Tram graphics</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Tram_graphics&amp;diff=8339"/>
		<updated>2012-05-03T16:47:29Z</updated>

		<summary type="html">&lt;p&gt;FooBar: use length instead of shorten_vehicle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is the HTM 4001 from the [http://dev.openttdcoop.org/projects/dutchtramset/repository Dutch Tram Set]. The original code and graphics for this are by FooBar. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This continues the [[NMLTutorial/Tram articulation|second part]] of the tram example. Now graphics will be added to the tram.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The graphics ==&lt;br /&gt;
As this tutorial is about coding NML and not about drawing graphics, we&#039;ll give you the graphics for free:&lt;br /&gt;
&lt;br /&gt;
[[Image:Htm 4001.png|frame|none|Graphics for each part of the HTM 4001. Drawn by FooBar.]]&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
The graphics in this file are templated (and actually use the templates used as example for the template chapter of this tutorial). That means we&#039;ll be using templates here as well. Check [[NMLTutorial/Template|back]] if you don&#039;t remember how to do that. These are the templates you should end up with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
template template_tram_28(x, y) {&lt;br /&gt;
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]&lt;br /&gt;
    [x,         y,          10,        28,           -4,         -11]&lt;br /&gt;
    [x+ 20,     y,          26,        28,          -17,         -14]&lt;br /&gt;
    [x+ 50,     y,          36,        28,          -20,         -20]&lt;br /&gt;
    [x+ 90,     y,          26,        28,           -9,         -15]&lt;br /&gt;
    [x+120,     y,          10,        28,           -4,         -13]&lt;br /&gt;
    [x+140,     y,          26,        28,          -16,         -16]&lt;br /&gt;
    [x+170,     y,          36,        28,          -16,         -20]&lt;br /&gt;
    [x+210,     y,          26,        28,           -8,         -16]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
template template_tram_24(x, y) {&lt;br /&gt;
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]&lt;br /&gt;
    [x,         y,          10,        28,           -4,         -11]&lt;br /&gt;
    [x+ 20,     y,          26,        28,          -17,         -14]&lt;br /&gt;
    [x+ 50,     y,          36,        28,          -22,         -20]&lt;br /&gt;
    [x+ 90,     y,          26,        28,           -9,         -15]&lt;br /&gt;
    [x+120,     y,          10,        28,           -4,         -15]&lt;br /&gt;
    [x+140,     y,          26,        28,          -16,         -16]&lt;br /&gt;
    [x+170,     y,          36,        28,          -14,         -20]&lt;br /&gt;
    [x+210,     y,          26,        28,           -8,         -16]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
template template_purchase(x, y) {&lt;br /&gt;
    //[left_x,  upper_y,    width,     height,     offset_x,     offset_y]&lt;br /&gt;
    [x,         y,          50,        12,          -25,          -6]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purchase menu sprite will be added on the next page, but it doesn&#039;t hurt to have the template defined now. Every template has arguments for the position of the top left sprite corner.&lt;br /&gt;
&lt;br /&gt;
=== Spritesets ===&lt;br /&gt;
With these templates, we can make three spritesets for the three vehicle parts. We give the spritesets proper names and include a reference to the image file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
spriteset(spriteset_real_htm_4001, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_28(0, 20)&lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_real_htm_4001_1, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_24(0, 60)&lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_real_htm_4001_2, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_28(0, 100)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the first and last vehicle part are 28 px long and use the 28 px template. The middle part is only 24 px long and uses the 24 px template.&lt;br /&gt;
&lt;br /&gt;
Because there are no different sprites for &amp;quot;empty&amp;quot;, &amp;quot;full&amp;quot;, &amp;quot;loaded&amp;quot; and &amp;quot;loading&amp;quot;, we don&#039;t have to define a spritegroup in this case. If you had different sprites for these different states, you would need to combine them in a spritegroup first.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Attaching the graphics with a switch block ==&lt;br /&gt;
From the graphics block we will use the &#039;&#039;default&#039;&#039; callback to reference the spritesets. However, because we can reference only one spriteset (or -group) from the graphics block, we need an intermediate switch block to decide the graphics depending on the position in the vehicle.&lt;br /&gt;
&lt;br /&gt;
So from the graphics block we reference a switch block for the default graphics:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
    graphics {&lt;br /&gt;
        articulated_part:        switch_articulated_htm_4001;&lt;br /&gt;
        cargo_capacity:          switch_capacity_htm_4001;&lt;br /&gt;
        default:                 switch_spriteset_htm_4001;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This then links to a switch block. The workings of this switch block will be similar to that of the cargo capacity callback, making a decicion based on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. However, this time we need three separate ranges (because three different spritesets) and we mustn&#039;t return a value but now reference these spritesets:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_spriteset_htm_4001, position_in_consist ) {&lt;br /&gt;
    1: spriteset_real_htm_4001_1;&lt;br /&gt;
    2: spriteset_real_htm_4001_2;&lt;br /&gt;
    spriteset_real_htm_4001; //default&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So for the second vehicle part (with index 1 in &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt;) we use the graphics of the &#039;spriteset_real_htm_4001_1&#039; spriteset block. For the last part (index 2) we use the &#039;&#039;spriteset_real_htm_4001_2&#039;&#039; spriteset. For all other parts (in this case only the first) we&#039;ll default to the &#039;&#039;spriteset_real_htm_4001&#039;&#039; spriteset.&lt;br /&gt;
&lt;br /&gt;
This has the graphics sorted and you can encode the NewGRF to see the result ingame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vehicle length callback ==&lt;br /&gt;
If you did encode the previous results, you&#039;ll notice that the individual vehicle parts are very far apart. This is because we used shorter sprites than the 32px default length. We&#039;ll need to tell the game that our vehicle parts are shorter!&lt;br /&gt;
&lt;br /&gt;
This is done by means of the vehicle length callback, incidentally named &amp;lt;code&amp;gt;length&amp;lt;/code&amp;gt; for use in the graphics block, look it up [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks here]. Because different parts have different lengths, we once more can&#039;t just return a value from the graphics block but need an intermediate switch block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
    graphics {&lt;br /&gt;
        articulated_part:        switch_articulated_htm_4001;&lt;br /&gt;
        length:                  switch_length_htm_4001; //&amp;lt;-- this one is added now&lt;br /&gt;
        cargo_capacity:          switch_capacity_htm_4001;&lt;br /&gt;
        default:                 switch_spriteset_htm_4001;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself will once more make a decision based on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; variable. The value to return for the callback is the desired length of the vehicle part, where 8 is longest possible length (32px) and 1 is the shortest possible length (4px). The first and last part of the vehicle are 28px, which equals a value of 7. The middle part is 24px, which equals a value of 6. The switch block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap;&amp;quot;&amp;gt;&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_length_htm_4001, position_in_consist) {&lt;br /&gt;
    1: return 6;&lt;br /&gt;
    return 7;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The second vehicle part (with index 1 in &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt;) returns value 6 and a default value 7 is returned for all other positions (the first and last part of the vehicle). Counting of the vehicle parts starts at zero and you only have to list the part numbers that differ from the default you&#039;ll be specifying. Once more notice that the identifier of the switch block is the same as that used in the graphics block.&lt;br /&gt;
&lt;br /&gt;
This should fix our vehicle and now the parts actually appear connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Total code so far ==&lt;br /&gt;
If you put everything in the correct order, you should have this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
// define the newgrf&lt;br /&gt;
grf {&lt;br /&gt;
	grfid:	&amp;quot;\FB\FB\01\02&amp;quot;;&lt;br /&gt;
	name:	string(STR_GRF_NAME);&lt;br /&gt;
	desc:	string(STR_GRF_DESCRIPTION);&lt;br /&gt;
	version:		REPO_REVISION;&lt;br /&gt;
	min_compatible_version:	87;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////&lt;br /&gt;
//Vehicle sprites//&lt;br /&gt;
///////////////////&lt;br /&gt;
&lt;br /&gt;
spriteset(spriteset_real_htm_4001, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_28(0, 20)&lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_real_htm_4001_1, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_24(0, 60)&lt;br /&gt;
}&lt;br /&gt;
spriteset(spriteset_real_htm_4001_2, &amp;quot;gfx/htm_4001.png&amp;quot;) {&lt;br /&gt;
    template_tram_28(0, 100)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_spriteset_htm_4001, position_in_consist ) {&lt;br /&gt;
    1: spriteset_real_htm_4001_1;&lt;br /&gt;
    2: spriteset_real_htm_4001_2;&lt;br /&gt;
    spriteset_real_htm_4001; //default&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////&lt;br /&gt;
//vehicle callbacks//&lt;br /&gt;
/////////////////////&lt;br /&gt;
&lt;br /&gt;
//set number of articulated parts&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_articulated_htm_4001, extra_callback_info1) {&lt;br /&gt;
    1..2: return item_tram_htm_4001; //use same vehicle for all parts&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS; //stop adding vehicle parts&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//set length of each part&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_length_htm_4001, position_in_consist) {&lt;br /&gt;
    1: return 6;&lt;br /&gt;
    return 7;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//set capacity of each part&lt;br /&gt;
switch (FEAT_ROADVEHS, SELF, switch_capacity_htm_4001, position_in_consist ) {&lt;br /&gt;
    1: return 26;&lt;br /&gt;
    return 38; //default&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////&lt;br /&gt;
//vehicle properties//&lt;br /&gt;
//////////////////////&lt;br /&gt;
&lt;br /&gt;
item (FEAT_ROADVEHS, item_tram_htm_4001) {&lt;br /&gt;
    property {&lt;br /&gt;
        name:                        string(STR_NAME_HTM_4001);&lt;br /&gt;
        introduction_date:           date(2006,1,1);&lt;br /&gt;
        model_life:                  VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        retire_early:                0;&lt;br /&gt;
        vehicle_life:                25;&lt;br /&gt;
        loading_speed:               25;&lt;br /&gt;
        cost_factor:                 224;&lt;br /&gt;
        running_cost_factor:         112;&lt;br /&gt;
        speed:                       81 km/h;&lt;br /&gt;
        power:                       966 hp;&lt;br /&gt;
        weight:                      58 ton;&lt;br /&gt;
        cargo_capacity:              (38*2+26)/3;&lt;br /&gt;
        tractive_effort_coefficient: 0.5;&lt;br /&gt;
        air_drag_coefficient:        0;&lt;br /&gt;
        //sound_effect:              no sound&lt;br /&gt;
        //visual_effect:             use default (none)&lt;br /&gt;
        &lt;br /&gt;
        //callback_flags:            no need to set this&lt;br /&gt;
        reliability_decay:           20;&lt;br /&gt;
        climates_available:          ALL_CLIMATES;&lt;br /&gt;
        refittable_cargo_classes:    bitmask(CC_PASSENGERS);&lt;br /&gt;
        sprite_id:                   SPRITE_ID_NEW_ROADVEH; //use custom sprites&lt;br /&gt;
        misc_flags:                  bitmask(ROADVEH_FLAG_TRAM); //make this a tram&lt;br /&gt;
        refit_cost:                  0; //refits are free&lt;br /&gt;
        running_cost_base:           RUNNING_COST_ROADVEH;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    graphics {&lt;br /&gt;
        articulated_part:        switch_articulated_htm_4001;&lt;br /&gt;
        length:                  switch_length_htm_4001;&lt;br /&gt;
        cargo_capacity:          switch_capacity_htm_4001;&lt;br /&gt;
        default:                 switch_spriteset_htm_4001;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The graphics are there, the tram seems complete. Or is it? There still is a sprite for the purchase menu left and if you&#039;ll look closely you&#039;ll notice that the capacity displayed in the purchase menu isn&#039;t correct. And remember the text we added to the language file to be displayed in the purchase menu? That&#039;s all next, in the last part of this tram example.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Tram articulation|Tram purchase menu}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_recolour&amp;diff=8338</id>
		<title>NMLTutorial/Train recolour</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_recolour&amp;diff=8338"/>
		<updated>2012-05-03T16:39:09Z</updated>

		<summary type="html">&lt;p&gt;FooBar: remove refittable_cargo_types&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the [http://dev.openttdcoop.org/projects/nml/repository/show/examples NML source]. The code for this was originally written in NFO by DJNekkid for the 2cc Trainset and rewritten in NML by Hirundo. The graphics used in the example are by Purno. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues and concludes the [[NMLTutorial/Train four part refit|fourth part]] of the train example. A parameter setting will be added (with a GUI for OpenTTD) to allow choosing between 1cc, 2cc or real life colours for our train. And we&#039;ll do some further visual improvements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== GRF Parameter setting ==&lt;br /&gt;
The GRF parameter setting will allow choosing between 1cc, 2cc or real life colours. This is done by adding a param block to the grf block. In this param block one (named) parameter will be defined:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
    param {&lt;br /&gt;
        /* There is one parameter, which can be used to alter the colour scheme */&lt;br /&gt;
        param_colour_scheme {&lt;br /&gt;
            type: int;&lt;br /&gt;
            name: string(STR_PARAM_COLOUR_SCHEME_NAME);&lt;br /&gt;
            desc: string(STR_PARAM_COLOUR_SCHEME_DESC);&lt;br /&gt;
            /* There are currently three possible values:&lt;br /&gt;
             * - 1cc&lt;br /&gt;
             * - 2cc (default)&lt;br /&gt;
             * - real-world&lt;br /&gt;
             */&lt;br /&gt;
            min_value: 0;&lt;br /&gt;
            max_value: 2;&lt;br /&gt;
            def_value: 1;&lt;br /&gt;
            names: {&lt;br /&gt;
                0: string(STR_PARAM_COLOUR_SCHEME_1CC);&lt;br /&gt;
                1: string(STR_PARAM_COLOUR_SCHEME_2CC);&lt;br /&gt;
                2: string(STR_PARAM_COLOUR_SCHEME_REAL);&lt;br /&gt;
            };&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GRF parameter is named &amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt;. This identifier needs to be unique and can be used elsewhere in the code to make decisions upon. Because we want three possible values, the GRF parameter needs to be of the integer type. The boolean type wouldn&#039;t work, as that only allows two possible values (on and off). The minimum value will be 0, the maximum 2 (resulting in three possible values 0, 1 and 2) and the default (in OpenTTD, TTDPatch always defaults to 0) will be 1. Strings are defined for the GRF parameter name and description. Each GRF parameter value will also get custom strings to display the settings rather than just numbers.&lt;br /&gt;
&lt;br /&gt;
This means we have to add these strings to the language file as well:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_NAME :Colour scheme&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_DESC :Select the type of colour scheme to use&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_1CC  :One company colour&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_2CC  :Two company colours&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_REAL :Real-world colours&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Colour mapping callback ==&lt;br /&gt;
This only added the parameter setting, but it doesn&#039;t do anything yet. We&#039;ll use the &amp;lt;code&amp;gt;colour_mapping&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback]. This callback allows recolouring a sprite using, well errr, recolour sprites. This is a slightly complicated callback, but the first step is easy. Reference a switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
        colour_mapping:               sw_icm_colour_mapping;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself we&#039;ll just give to you, attempting to explain what it does afterwards. If you don&#039;t understand how this switch block works, just copy it or ignore the callback altogether. Try yourself at some more easy NewGRFs first to get the hang of NML and come back to this later.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_colour_mapping, param_colour_scheme) {&lt;br /&gt;
    /* Emulate 1cc by making the first colour always yellow, this looks much better (and more realistic) */&lt;br /&gt;
    0: return palette_2cc(COLOUR_YELLOW, company_colour1);&lt;br /&gt;
    /* Use realistic colours, i.e. yellow + dark blue */&lt;br /&gt;
    2: return palette_2cc(COLOUR_YELLOW, COLOUR_DARK_BLUE);&lt;br /&gt;
    /* Use the default, i.e. 2 company colours */&lt;br /&gt;
    return base_sprite_2cc + CB_RESULT_COLOUR_MAPPING_ADD_CC;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The decision of this switch block is made on the &amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt;. The name of this variable is what we gave to it when defining the param block, so that&#039;s how you use a predefined GRF parameter. The values this GRF parameter can have are those defined in the same param block, so these values can be used as range in the switch block. It&#039;s useful to consider one value as default here, in case a user manages to make a setting outside the range of the minimum and maximum GRF parameter setting.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;colour_mapping&amp;lt;/code&amp;gt; needs to return the sprite number of a recolour sprite. We&#039;ll be using the default recolour sprites for this and NML has some functions and variables to retrieve these sprite numbers for you. You can find more about that in the [http://newgrf-specs.tt-wiki.net/wiki/NML:List_of_default_colour_translation_palettes NML Documentation].&lt;br /&gt;
; 1cc (&amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt; == 0)&lt;br /&gt;
: Here we use the &amp;lt;code&amp;gt;palette_2cc&amp;lt;/code&amp;gt; function even though we only want 1cc. To make the train look better we make one of the two company colours yellow rather than keeping the normal company colour range, using the &amp;lt;code&amp;gt;COLOUR_YELLOW&amp;lt;/code&amp;gt; from the default [http://newgrf-specs.tt-wiki.net/wiki/NML:List_of_default_colour_translation_palettes#Company_colour_helper_functions colour constants]. The other company colour will depend on what first company colour the user has selected, which we&#039;ll get from the &amp;lt;code&amp;gt;company_colour1&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables vehicle variable].&lt;br /&gt;
; real life colours (&amp;lt;code&amp;gt;param_colour_scheme&amp;lt;/code&amp;gt; == 2)&lt;br /&gt;
: The real life colours of this Dutch NS train are blue and yellow. We can force the train to be recoloured in these colours regardless of the company colours selected by the user. This is similar to the 1cc recolour from above, but now we return two specific colours rather than depend on the company colour variable.&lt;br /&gt;
; 2cc (default)&lt;br /&gt;
: This is what will be used as default if the GRF parameter setting is not equal to 0 or 2. Here a different way of returning the recolour sprite is used. The sprite number of the first 2cc recolour sprite can be found with the &amp;lt;code&amp;gt;base_sprite_2cc&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:General#General_variables variable]. Add &amp;lt;code&amp;gt;CB_RESULT_COLOUR_MAPPING_ADD_CC&amp;lt;/code&amp;gt; to this (see the [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback description]) to find the company colours used.&lt;br /&gt;
&lt;br /&gt;
With that the GRF parameter setting to choose the vehicle colours is done.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Visual effect ==&lt;br /&gt;
The train currently has a visual effect (electric spark) on all parts of the vehicle, but only the first part has a pantograph. We can limit the effect to only this first part by using the &amp;lt;code&amp;gt;visual_effect_and_powered&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback]. Making a decision only on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] we can do this using a conditional assignment directly from the graphics block without the need for a switch block:&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
        visual_effect_and_powered:    return (position_in_consist % 4 == 0) ?&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER) :&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the first part of the vehicle we return the electric spark [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Train_properties visual effect] with an offset of 2 and not making this a powered wagon. For all other parts we disable the visual effect (offset doesn&#039;t matter now) and also not make this a powered wagon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lights out ==&lt;br /&gt;
There&#039;s one more thing that can be improved about this train. We still have not used the sprites that show no lights at the front and rear of the train. It would be nice if two EMUs are coupled that there are no lights on where the coupling is, only at the front and back.&lt;br /&gt;
&lt;br /&gt;
For this we have to change the graphics switch block, not referencing the spritesets for back and front directly, but using an intermediate switch block to decide if we want lights or not.&lt;br /&gt;
&lt;br /&gt;
Change the current switch block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      sw_icm_graphics_front;&lt;br /&gt;
    3:      sw_icm_graphics_rear;&lt;br /&gt;
    sw_icm_graphics_middle;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This now links to two additional switch blocks, one for the front and one for the rear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;
/* Only the frontmost vehicle should have its lights on */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_front, position_in_consist) {&lt;br /&gt;
    0: set_icm_front_lighted;&lt;br /&gt;
    set_icm_front;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Only the rearmost vehicle should have red lights */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_rear, position_in_consist_from_end) {&lt;br /&gt;
    0: set_icm_rear_lighted;&lt;br /&gt;
    set_icm_rear;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case of the front part, we make a decision based on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. If it&#039;s the very first of the consist, show front lights, otherwise show no front lights for further connected EMUs.&lt;br /&gt;
&lt;br /&gt;
In case of the last part, we make a decision based on the &amp;lt;code&amp;gt;position_in_consist_from_end&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. This counts exactly opposite than &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt;, now starting from the back. If it&#039;s the very last of the consist, show rear lights, otherwise show no rear lights for further connected EMUs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Total code so far ==&lt;br /&gt;
When put in the correct order, this should now encode as a working NewGRF. The total code so far:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example small&amp;quot;&amp;gt;&lt;br /&gt;
/* Define grf */&lt;br /&gt;
grf {&lt;br /&gt;
    grfid: &amp;quot;NML\00&amp;quot;;&lt;br /&gt;
    /* GRF name and description strings are defined in the lang files */&lt;br /&gt;
    name: string(STR_GRF_NAME);&lt;br /&gt;
    desc: string(STR_GRF_DESC);&lt;br /&gt;
    /* This is the first version, start numbering at 0. */&lt;br /&gt;
    version: 0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
&lt;br /&gt;
    /* Define user-configurable parameters */&lt;br /&gt;
    param {&lt;br /&gt;
        /* There is one parameter, which can be used to alter the colour scheme */&lt;br /&gt;
        param_colour_scheme {&lt;br /&gt;
            type: int;&lt;br /&gt;
            name: string(STR_PARAM_COLOUR_SCHEME_NAME);&lt;br /&gt;
            desc: string(STR_PARAM_COLOUR_SCHEME_DESC);&lt;br /&gt;
            /* There are currently three possible values:&lt;br /&gt;
             * - 1cc&lt;br /&gt;
             * - 2cc (default)&lt;br /&gt;
             * - real-world&lt;br /&gt;
             */&lt;br /&gt;
            min_value: 0;&lt;br /&gt;
            max_value: 2;&lt;br /&gt;
            def_value: 1;&lt;br /&gt;
            names: {&lt;br /&gt;
                0: string(STR_PARAM_COLOUR_SCHEME_1CC);&lt;br /&gt;
                1: string(STR_PARAM_COLOUR_SCHEME_2CC);&lt;br /&gt;
                2: string(STR_PARAM_COLOUR_SCHEME_REAL);&lt;br /&gt;
            };&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define a rail type table,&lt;br /&gt;
 * this allows referring to railtypes&lt;br /&gt;
 * irrespective of the grfs loaded.&lt;br /&gt;
 */&lt;br /&gt;
railtypetable {&lt;br /&gt;
    ELRL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Basic template for 4 vehicle views */&lt;br /&gt;
template tmpl_vehicle_basic(x, y) {&lt;br /&gt;
    // arguments x, y: coordinates of top-left corner of first sprite&lt;br /&gt;
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xrel yrel&lt;br /&gt;
    [x +  9, y, 22, 20, -14, -12]&lt;br /&gt;
    [x + 32, y, 32, 16, -16, -12]&lt;br /&gt;
    [x + 65, y, 22, 20,  -6, -12]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with only 4 views (symmetric) */&lt;br /&gt;
template tmpl_vehicle_4_views(num) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    tmpl_vehicle_basic(1, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with 8 views (non-symmetric) */&lt;br /&gt;
template tmpl_vehicle_8_views(num, reversed) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    // argument reversed: Reverse visible orientation of vehicle, if set to 1&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a single vehicle sprite */&lt;br /&gt;
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {&lt;br /&gt;
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the spritesets, these allow referring to these sprites later on */&lt;br /&gt;
spriteset (set_icm_front_lighted, &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(0, 0) }&lt;br /&gt;
spriteset (set_icm_rear_lighted,  &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(1, 1) }&lt;br /&gt;
spriteset (set_icm_front,         &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(2, 0) }&lt;br /&gt;
spriteset (set_icm_rear,          &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(3, 1) }&lt;br /&gt;
spriteset (set_icm_middle,        &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_4_views(4)    }&lt;br /&gt;
spriteset (set_icm_purchase,      &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(5, 53, 14, -25, -10) }&lt;br /&gt;
spriteset (set_icm_invisible,     &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(6,  1,  1,   0,   0) }&lt;br /&gt;
&lt;br /&gt;
/* --- Graphics callback  --- */&lt;br /&gt;
&lt;br /&gt;
/* Only the frontmost vehicle should have its lights on */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_front, position_in_consist) {&lt;br /&gt;
    0: set_icm_front_lighted;&lt;br /&gt;
    set_icm_front;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Only the rearmost vehicle should have red lights */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_rear, position_in_consist_from_end) {&lt;br /&gt;
    0: set_icm_rear_lighted;&lt;br /&gt;
    set_icm_rear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* In the 3-part version, the 3rd car is invisible */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_middle, ((position_in_consist % 4) == 2) &amp;amp;&amp;amp; (cargo_subtype == 0)) {&lt;br /&gt;
    1: set_icm_invisible;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      sw_icm_graphics_front;&lt;br /&gt;
    3:      sw_icm_graphics_rear;&lt;br /&gt;
    sw_icm_graphics_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Cargo subtype text --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_cargo_subtype_text, cargo_subtype) {&lt;br /&gt;
    0: return string(STR_ICM_SUBTYPE_3_PART);&lt;br /&gt;
    1: return string(STR_ICM_SUBTYPE_4_PART);&lt;br /&gt;
    return 0xFF;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Colour mapping callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_colour_mapping, param_colour_scheme) {&lt;br /&gt;
    /* Emulate 1cc by making the first colour always yellow, this looks much better (and more realistic) */&lt;br /&gt;
    0: return palette_2cc(COLOUR_YELLOW, company_colour1);&lt;br /&gt;
    /* Use realistic colours, i.e. yellow + dark blue */&lt;br /&gt;
    2: return palette_2cc(COLOUR_YELLOW, COLOUR_DARK_BLUE);&lt;br /&gt;
    /* Use the default, i.e. 2 company colours */&lt;br /&gt;
    return base_sprite_2cc + CB_RESULT_COLOUR_MAPPING_ADD_CC;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Articulated part callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add three articulated parts, for a total of four */&lt;br /&gt;
    1 .. 3: return item_icm;&lt;br /&gt;
    return 0xFF;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Start/stop callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12-16 cars) */&lt;br /&gt;
    1 .. 16: return 0xFF;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Wagon attach callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_can_attach_wagon, vehicle_type_id) {&lt;br /&gt;
    /* SELF refers to the wagon here, check that it&#039;s an ICM */&lt;br /&gt;
    item_icm: return CB_RESULT_ATTACH_ALLOW;&lt;br /&gt;
    return string(STR_ICM_CANNOT_ATTACH_OTHER);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Shorten vehicle callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_3_part_vehicle, position_in_consist % 4) {&lt;br /&gt;
    /* In the three part version, shorten the 2nd vehicle to 7/8 and the 3rd to 1/8&lt;br /&gt;
     * The rear (1/8) part is then made invisisble */&lt;br /&gt;
    1: return SHORTEN_TO_7_8;&lt;br /&gt;
    2: return SHORTEN_TO_1_8;&lt;br /&gt;
    return SHORTEN_TO_8_8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_vehicle, cargo_subtype) {&lt;br /&gt;
    0: sw_icm_shorten_3_part_vehicle;&lt;br /&gt;
    return SHORTEN_TO_8_8; // 4-part vehicle needs no shortening&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Power, weight and TE are all applied to the front vehicle only */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_power, cargo_subtype) {&lt;br /&gt;
    0: return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
    return int(1890 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_weight, cargo_subtype) {&lt;br /&gt;
    0: return 144; //ton, 3 part train&lt;br /&gt;
    return 192; //ton, 4 part train&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_te, cargo_subtype) {&lt;br /&gt;
    /* Base TE coefficient = 0.3&lt;br /&gt;
     * 3 parts: 4/12 of weight on driving wheels&lt;br /&gt;
     * 4 parts: 6/16 of weight on driving wheels */&lt;br /&gt;
    0: return int(0.3 * 255 / 3);&lt;br /&gt;
    return int(0.3 * 255 * 3 / 8);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the actual train */&lt;br /&gt;
item(FEAT_TRAINS, item_icm) {&lt;br /&gt;
    /* Define properties first, make sure to set all of them */&lt;br /&gt;
    property {&lt;br /&gt;
        name:                         string(STR_ICM_NAME);&lt;br /&gt;
        // not available in toyland:&lt;br /&gt;
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); &lt;br /&gt;
        introduction_date:            date(1983, 1, 1);&lt;br /&gt;
        model_life:                   VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        vehicle_life:                 30;&lt;br /&gt;
        reliability_decay:            20;&lt;br /&gt;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);&lt;br /&gt;
        non_refittable_cargo_classes: bitmask();&lt;br /&gt;
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling&lt;br /&gt;
        // It&#039;s an intercity train, loading is relatively slow:&lt;br /&gt;
        loading_speed:                6; &lt;br /&gt;
        cost_factor:                  45;&lt;br /&gt;
        running_cost_factor:          100; // Changed by callback&lt;br /&gt;
        sprite_id:                    SPRITE_ID_NEW_TRAIN;&lt;br /&gt;
        speed:                        141 km/h; // actually 140, but there are rounding errors&lt;br /&gt;
        misc_flags:                   bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);&lt;br /&gt;
        refit_cost:                   0; //refit costs don&#039;t apply to subcargo display &lt;br /&gt;
        // callback flags are not set manually&lt;br /&gt;
        track_type:                   ELRL; // from rail type table&lt;br /&gt;
        ai_special_flag:              AI_FLAG_PASSENGER;&lt;br /&gt;
        power:                        1260 kW; // Changed by CB&lt;br /&gt;
        running_cost_base:            RUNNING_COST_ELECTRIC;&lt;br /&gt;
        dual_headed:                  0;&lt;br /&gt;
        cargo_capacity:               36; // per part, changed by callback&lt;br /&gt;
        weight:                       144 ton; // Total, changed by callback&lt;br /&gt;
        ai_engine_rank:               0; // not intended to be used by the ai&lt;br /&gt;
        engine_class:                 ENGINE_CLASS_ELECTRIC;&lt;br /&gt;
        extra_power_per_wagon:        0 kW;&lt;br /&gt;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:&lt;br /&gt;
        tractive_effort_coefficient:  0.3 / 3; // changed by callback&lt;br /&gt;
        air_drag_coefficient:         0.06;&lt;br /&gt;
        shorten_vehicle:              SHORTEN_TO_8_8;&lt;br /&gt;
        // Overridden by callback to disable for non-powered wagons:&lt;br /&gt;
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);&lt;br /&gt;
        extra_weight_per_wagon:       0 ton;&lt;br /&gt;
        bitmask_vehicle_info:         0;&lt;br /&gt;
    }&lt;br /&gt;
    /* Define graphics and callbacks&lt;br /&gt;
     * Setting all callbacks is not needed, only define what is used */&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:                      sw_icm_graphics;&lt;br /&gt;
        purchase:                     set_icm_purchase;&lt;br /&gt;
        cargo_subtype_text:           sw_icm_cargo_subtype_text;&lt;br /&gt;
        additional_text:              return string(STR_ICM_ADDITIONAL_TEXT);&lt;br /&gt;
        colour_mapping:               sw_icm_colour_mapping;&lt;br /&gt;
        start_stop:                   sw_icm_start_stop;&lt;br /&gt;
        articulated_part:             sw_icm_articulated_part;&lt;br /&gt;
        can_attach_wagon:             sw_icm_can_attach_wagon;&lt;br /&gt;
        running_cost_factor:          return (cargo_subtype == 1) ? 150 : 100;&lt;br /&gt;
        /* Capacity is per part */&lt;br /&gt;
        cargo_capacity:               return (cargo_subtype == 0) &amp;amp;&amp;amp; ((position_in_consist % 4) == 2) ? 0 : 36;&lt;br /&gt;
        /* In the purchase menu, we want to show the capacity for the three-part version,&lt;br /&gt;
         * i.e. divide the capacity of three cars across four */&lt;br /&gt;
        purchase_cargo_capacity:      return 36 * 3 / 4;&lt;br /&gt;
        /* Only the front vehicle has a visual effect */&lt;br /&gt;
        visual_effect_and_powered:    return (position_in_consist % 4 == 0) ?&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER) :&lt;br /&gt;
                                          visual_effect_and_powered(VISUAL_EFFECT_DISABLE, 0, DISABLE_WAGON_POWER);&lt;br /&gt;
        shorten_vehicle:              sw_icm_shorten_vehicle;&lt;br /&gt;
        /* Only the front vehicle has power */&lt;br /&gt;
        power:                        sw_icm_power;&lt;br /&gt;
        //purchase_power:               return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
        /* Only the front vehicle has weight */&lt;br /&gt;
        weight:                       sw_icm_weight;&lt;br /&gt;
        /* Only the front vehicle has TE */&lt;br /&gt;
        tractive_effort_coefficient:  sw_icm_te;&lt;br /&gt;
        /* Only 1/3 of the weight is on the driving weels. */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The complete language file ===&lt;br /&gt;
english.lng now contains this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;example small&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
&lt;br /&gt;
STR_GRF_NAME                 :NML Example NewGRF: Train&lt;br /&gt;
STR_GRF_DESC                 :{ORANGE}NML Example NewGRF: Train{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}Purno, {BLACK}coding by {SILVER}DJNekkid.{}{BLACK}This NewGRF defines a Dutch EMU, the ICM &#039;Koploper&#039;.&lt;br /&gt;
&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_NAME :Colour scheme&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_DESC :Select the type of colour scheme to use&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_1CC  :One company colour&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_2CC  :Two company colours&lt;br /&gt;
STR_PARAM_COLOUR_SCHEME_REAL :Real-world colours&lt;br /&gt;
&lt;br /&gt;
STR_ICM_NAME                 :ICM &#039;Koploper&#039; (Electric)&lt;br /&gt;
STR_ICM_ADDITIONAL_TEXT      :Choose between 3- and 4-part EMU via refit{}Stated values are for the 3-part variant, the 4-part version has 33% more capacity and 50% more power and running cost.&lt;br /&gt;
STR_ICM_SUBTYPE_3_PART       : (3 parts)&lt;br /&gt;
STR_ICM_SUBTYPE_4_PART       : (4 parts)&lt;br /&gt;
STR_ICM_CANNOT_START         :... train too long (max. 4 coupled EMUs).&lt;br /&gt;
STR_ICM_CANNOT_ATTACH_OTHER  :... only other ICMs can be attached to ICM.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now our train is really completed and that makes this the end of the train example.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Parameters|Object}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_four_part_refit&amp;diff=8337</id>
		<title>NMLTutorial/Train four part refit</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_four_part_refit&amp;diff=8337"/>
		<updated>2012-05-03T16:38:36Z</updated>

		<summary type="html">&lt;p&gt;FooBar: remove refittable_cargo_types&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the [http://dev.openttdcoop.org/projects/nml/repository/show/examples NML source]. The code for this was originally written in NFO by DJNekkid for the 2cc Trainset and rewritten in NML by Hirundo. The graphics used in the example are by Purno. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues the [[NMLTutorial/Train three part articulated|third part]] of the train example. The three part EMU will be made refittable to a four part EMU.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What&#039;s going to happen ==&lt;br /&gt;
A lot of things need to be added to make this train refittable between three and four parts.&lt;br /&gt;
&lt;br /&gt;
The method used to do this is actually the other way round than the user will think from the behaviour ingame. The train will be changed to a four part EMU. For the (default) three part refit one of these four parts will be hidden. A lot of switches will be used to make the train look right, make it have the correct capacity, power, weight, running costs and tractive effort.&lt;br /&gt;
&lt;br /&gt;
There are some drawbacks to this method. There&#039;s no way to charge the user for puchasing the extra vehicle part. Also autoreplacing will be difficult, as there&#039;s now way for the user to select which vehicle length they want. For that reason the author of this tutorial thinks making two different vehicles and having both available from the purchase menu is a better solution, but this method is a good illustration for some of the more advanced features of NML. It&#039;s up to you to decide which implementation you think is best for your vehicles.&lt;br /&gt;
&lt;br /&gt;
What we&#039;ll be doing:&lt;br /&gt;
* Add the refit option;&lt;br /&gt;
* Make the graphics work;&lt;br /&gt;
* Add callbacks to supply the correct vehicle properties;&lt;br /&gt;
* Make the purchase menu display the correct values.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Refit option ==&lt;br /&gt;
The refit option will be added by means of the &amp;quot;cargo subtype&amp;quot;. This allows to split each cargo into multiple entities which can be assigned different properties by means of other callbacks.&lt;br /&gt;
&lt;br /&gt;
The first step towards this is defining names for these separate entries using the &amp;lt;code&amp;gt;cargo_subtype_text&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback]. This callback requires the use of a switch, so reference a switch from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        cargo_subtype_text:           sw_icm_cargo_subtype_text;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch itself will use the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. This variable starts at 0 and will be increased by 1 until the callback returns &amp;lt;code&amp;gt;CB_RESULT_NO_MORE_ARTICULATED_PARTS&amp;lt;/code&amp;gt;. Return strings to use as cargo subtype. Each returned string will be a separate cargo subtype:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_cargo_subtype_text, cargo_subtype) {&lt;br /&gt;
    0: return string(STR_ICM_SUBTYPE_3_PART);&lt;br /&gt;
    1: return string(STR_ICM_SUBTYPE_4_PART);&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This adds two cargo subtypes. Also add these strings to the language file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
STR_ICM_SUBTYPE_3_PART       : (3 parts)&lt;br /&gt;
STR_ICM_SUBTYPE_4_PART       : (4 parts)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
The graphics defined previously were for a three part vehicle. Now we have to make this into a four part vehicle and hide one wagon for the three part refit.&lt;br /&gt;
&lt;br /&gt;
=== Four part articulated vehicle ===&lt;br /&gt;
In order to make the vehicle four parts, the articulated vehicle callback switch needs to be changed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add three articulated parts, for a total of four */&lt;br /&gt;
    1 .. 3: return item_icm;&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is done by changing the value range from &amp;lt;code&amp;gt;1 .. 2&amp;lt;/code&amp;gt; into &amp;lt;code&amp;gt;1 .. 3&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Start/stop callback ===&lt;br /&gt;
The start/stop callback checking the vehicle length needs to be changed as well. If we still want a maximum of four EMUs, the maximum length will now be 4 * 4 instead of 4 * 3. This means changing the switch for this callback:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12-16 cars) */&lt;br /&gt;
    1 .. 16: return CB_RESULT_NO_TEXT;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is done by changing the value range from &amp;lt;code&amp;gt;1 .. 12&amp;lt;/code&amp;gt; into &amp;lt;code&amp;gt;1 .. 16&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Graphics ===&lt;br /&gt;
Now that the vehicle is four parts, the default graphics switch needs to be changed as well to allow for two middle parts instead of one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      set_icm_front_lighted;&lt;br /&gt;
    3:      set_icm_rear_lighted;&lt;br /&gt;
    sw_icm_graphics_middle;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of modulo 3 we&#039;re now taking modulo 4. And the value for the rear vehicle part was changed from 2 to 3. For the middle parts, we also need to hide the one of the wagons for the three part EMU. Therefore we can&#039;t directly reference the spriteset but need an extra intermediate switch block.&lt;br /&gt;
&lt;br /&gt;
The extra switch block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_middle, ((position_in_consist % 4) == 2) &amp;amp;&amp;amp; (cargo_subtype == 0)) {&lt;br /&gt;
    1: set_icm_invisible;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even an expression this advanced can be used for switch block decision. Here we again check the position of the vehicle part, but also which cargo subtype is used for this vehicle. If it is the three part EMU (cargo subtype 0) AND it is the third vehicle part (position 2 counting from 0), we hide this vehicle part by displaying no graphics for it. In all other cases we display the regular middle part.&lt;br /&gt;
&lt;br /&gt;
=== Vehicle length ===&lt;br /&gt;
If you were to encode the result so far as a NewGRF, you end up with a three part train that has a big gap between the second and last part. This is because it&#039;s essentially still a four part vehicle, just with no graphics for the third part. This can be solved by changing the length of the two middle parts. If we make the second part (7/8) long and the third part (1/8), both together are a full wagon length, completely hiding the invisible third part.&lt;br /&gt;
&lt;br /&gt;
This is done by means of the &amp;lt;code&amp;gt;shorten_vehicle&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback], referencing a switch block as we first need to differentiate between the two cargo subtypes and then by the position in consist. Reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        shorten_vehicle:              sw_icm_shorten_vehicle;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we get the two switch blocks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* --- Shorten vehicle callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_3_part_vehicle, position_in_consist % 4) {&lt;br /&gt;
    /* In the three part version, shorten the 2nd vehicle to 7/8 and the 3rd to 1/8&lt;br /&gt;
     * The rear (1/8) part is then made invisisble */&lt;br /&gt;
    1: return SHORTEN_TO_7_8;&lt;br /&gt;
    2: return SHORTEN_TO_1_8;&lt;br /&gt;
    return SHORTEN_TO_8_8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_vehicle, cargo_subtype) {&lt;br /&gt;
    0: sw_icm_shorten_3_part_vehicle;&lt;br /&gt;
    return SHORTEN_TO_8_8; // 4-part vehicle needs no shortening&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The second of these switch blocks (called first from the graphics block) differentiates between the two cargo subtypes. For subtype 0 (three part vehicle) we need to do the shortenings and reference the first switch block. For the four part vehicle we need no shortening, so directly return to &amp;quot;shorten&amp;quot; to full length.&lt;br /&gt;
&lt;br /&gt;
The first switch again makes a decision based on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] we&#039;ve seen several times now. As said, the second part will be shortened to (7/8), the third part to (1/8) and the front and back part are kept full length (8/8).&lt;br /&gt;
&lt;br /&gt;
Now the vehicle looks good in both refits.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vehicle properties ==&lt;br /&gt;
Both refits still have identical properties. Surely the four part EMU has a higher capacity. We&#039;ll also change the running costs, power, weight and tractive effort depending on the refit chosen. This is all done by callbacks. You can find the available vehicle callbacks [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks here], with the second table especially on callbacks that change certain properties.&lt;br /&gt;
&lt;br /&gt;
=== Running cost factor ===&lt;br /&gt;
You can easily imagine that the longer vehicle will be more expensive to run. The three part has a running cost factor of 100, the four part will get a factor of 150. This requires adding the &amp;lt;code&amp;gt;running_cost_factor&amp;lt;/code&amp;gt; callback to the graphics block. From there we can link to a switch block and base the decision on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. A different method as shown below is not to use a switch block but to make the decision directly from the graphics block using a conditional assignment. We&#039;ve used a conditional assignment [[Train_single_engine#Templates|before]] in one of the template blocks.&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        running_cost_factor:          return (cargo_subtype == 1) ? 150 : 100;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; is 1 (the four part vehicle), a running cost factor of 150 is used. Otherwise, a factor of 100 is used. If you&#039;d rather used a switch block then that&#039;s up to you. Just reference one from the graphics block instead of the conditional assignment and use the switch block to make the decision based on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
=== Cargo capacity ===&lt;br /&gt;
The cargo capacity is 36 passengers per unit. Now the three part EMU will have a capacity that is too high, because it technically is a four part EMU with one part hidden. We need to give this hidden part 0 capacity.&lt;br /&gt;
&lt;br /&gt;
This is done by the &amp;lt;code&amp;gt;cargo_capacity&amp;lt;/code&amp;gt; callback. If the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; is 0 and the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; is the third part, we give it 0 capacity. Else it will get 36 capacity. Also this can be done directly from the graphics block, using a slightly more advanced conditional assignment. Of course you could again have used a switch block here, but there&#039;s no need for that in this case.&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
cargo_capacity:               return (cargo_subtype == 0) &amp;amp;&amp;amp; ((position_in_consist % 4) == 2) ? 0 : 36;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Power ===&lt;br /&gt;
The power of the four part vehicle will be higher. Let&#039;s use a switch block this time. Of course a conditional assignment could be used here, but compare this example with the running cost factor yourself. The callback used here is called &amp;lt;code&amp;gt;power&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        power:                        sw_icm_power;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself will again make a decision based on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable. The callback must return the vehicle power in horsepower (imperial) and this must be an integer value. Because we know the power in kW, a little calculation is needed which NML can do for you. Returning the integer is done by the &amp;lt;code&amp;gt;int()&amp;lt;/code&amp;gt; function that turns a (decimal) number into an integer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_power, cargo_subtype) {&lt;br /&gt;
    0: return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
    return int(1890 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Weight ===&lt;br /&gt;
Of course you could have done the calculation yourself and put the rounded values in the switch block. That we&#039;ll do for the weight of the vehicle. The callback used here is called &amp;lt;code&amp;gt;weight&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Again, reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
weight:                       sw_icm_weight;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The switch block itself will again make a decision based on the &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable. The weight here must be specified in tons:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_weight, cargo_subtype) {&lt;br /&gt;
    0: return 144; //ton, 3 part train&lt;br /&gt;
    return 192; //ton, 4 part train&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tractive effort coefficient===&lt;br /&gt;
The last property to sort out is the tractive effort. The callback used here is called &amp;lt;code&amp;gt;tractive_effort_coefficient&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Again, reference the switch block from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        tractive_effort_coefficient:  sw_icm_te;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the switch block we&#039;ll actually calculate the tractive effort coefficient:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_te, cargo_subtype) {&lt;br /&gt;
    /* Base TE coefficient = 0.3&lt;br /&gt;
     * 3 parts: 4/12 of weight on driving wheels&lt;br /&gt;
     * 4 parts: 6/16 of weight on driving wheels */&lt;br /&gt;
    0: return int(0.3 * 255 / 3);&lt;br /&gt;
    return int(0.3 * 255 * 3 / 8);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;The technical background of the tractive effort coefficient is that it must be supplied as value between 0 and 255, with 255 equal to 100%. The tractive effort coefficient itself is calculated by multiplying the friction coefficient (see [http://en.wikipedia.org/wiki/Rail_adhesion Wikipedia] for it&#039;s meaning) with the percentage of weight that is on driven wheels. I this case we use a friction of 30%. In real life the three part vehicle has 12 axles of which 4 powered. The four part vehicle has 16 axles of which 6 powered. Assuming an equal distribution of weight along the length of the vehicle, the three part vehicle has 33.3% of it&#039;s weight on powered wheels. The four part vehicle has 37.5% of it&#039;s weight on powered wheels. Multiply both by the friction coefficient and the factor of 255 and you have the tractive effort coefficient.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you don&#039;t provide a tractive effort coefficient, the game will assume a friction coefficient of 0.3 and all axles powered. A tractive effort coefficient of 100% you&#039;ll only get with 100% friction and and all axles powered. This is unrealistic for railroads but can be used for maglev when there actually is no contact between vehicle and guideway.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purchase menu ==&lt;br /&gt;
With all these callbacks we&#039;ve sort of broken the display of properties in the purchase menu. This is because the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] is not available in the purchase menu and &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt; variable is always 0 in the purchase menu. The latter can be to our advantage if we want to display the properties of the shorter refit, but the other needs some fixing.&lt;br /&gt;
&lt;br /&gt;
=== Running cost factor ===&lt;br /&gt;
This callback was only based on &amp;lt;code&amp;gt;cargo_subtype&amp;lt;/code&amp;gt;, so no fixing needed here.&lt;br /&gt;
&lt;br /&gt;
=== Cargo capacity ===&lt;br /&gt;
The capacity used both variables, so some fixing is in order here. We want to display 36*3 as capacity. Because capacity is defined per unit and our vehicle is technically four units, we need to divide this over four units: 36*3/4. Add the &amp;lt;code&amp;gt;purchase_cargo_capacity&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback] to the graphics block and return this value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        purchase_cargo_capacity:      return 36 * 3 / 4;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Power, weight and tractive effort coefficient ===&lt;br /&gt;
Luckily, these are also only based on the cargo subtype variable, so no fixing needed. If you wanted a different value to be displayed in the purchase menu, you&#039;d use the &amp;lt;code&amp;gt;purchase_power&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;purchase_weight&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;purchase_tractive_effort_coefficient&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callbacks] to do this. And if you want to know, the running cost factor would logically use the &amp;lt;code&amp;gt;purchase_running_cost_factor&amp;lt;/code&amp;gt; callback.&lt;br /&gt;
&lt;br /&gt;
=== Additional text ===&lt;br /&gt;
We want to inform the user that this train has an option to refit it into a four part version and that the properties shown are for the three part version. For this we&#039;ll use the &amp;lt;code&amp;gt;additional_text&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks callback] which we also used in the tram example. It can directly return a string from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        additional_text:              return string(STR_ICM_ADDITIONAL_TEXT);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also don&#039;t forget to add this string to the language file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
STR_ICM_ADDITIONAL_TEXT      :Choose between 3- and 4-part EMU via refit{}Stated values are for the 3-part variant, the 4-part version has 33% more capacity and 50% more power and running cost.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This means our vehicle now works like it should with the two refits. Encode it into a NewGRF if you like.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Total code so far ==&lt;br /&gt;
When put in the correct order, this should now encode as a working NewGRF. The total code so far:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
/* Define grf */&lt;br /&gt;
grf {&lt;br /&gt;
    grfid: &amp;quot;NML\00&amp;quot;;&lt;br /&gt;
    /* GRF name and description strings are defined in the lang files */&lt;br /&gt;
    name: string(STR_GRF_NAME);&lt;br /&gt;
    desc: string(STR_GRF_DESC);&lt;br /&gt;
    /* This is the first version, start numbering at 0. */&lt;br /&gt;
    version: 0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define a rail type table,&lt;br /&gt;
 * this allows referring to railtypes&lt;br /&gt;
 * irrespective of the grfs loaded.&lt;br /&gt;
 */&lt;br /&gt;
railtypetable {&lt;br /&gt;
    ELRL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Basic template for 4 vehicle views */&lt;br /&gt;
template tmpl_vehicle_basic(x, y) {&lt;br /&gt;
    // arguments x, y: coordinates of top-left corner of first sprite&lt;br /&gt;
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xrel yrel&lt;br /&gt;
    [x +  9, y, 22, 20, -14, -12]&lt;br /&gt;
    [x + 32, y, 32, 16, -16, -12]&lt;br /&gt;
    [x + 65, y, 22, 20,  -6, -12]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with only 4 views (symmetric) */&lt;br /&gt;
template tmpl_vehicle_4_views(num) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    tmpl_vehicle_basic(1, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with 8 views (non-symmetric) */&lt;br /&gt;
template tmpl_vehicle_8_views(num, reversed) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    // argument reversed: Reverse visible orientation of vehicle, if set to 1&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a single vehicle sprite */&lt;br /&gt;
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {&lt;br /&gt;
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the spritesets, these allow referring to these sprites later on */&lt;br /&gt;
spriteset (set_icm_front_lighted, &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(0, 0) }&lt;br /&gt;
spriteset (set_icm_rear_lighted,  &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(1, 1) }&lt;br /&gt;
spriteset (set_icm_front,         &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(2, 0) }&lt;br /&gt;
spriteset (set_icm_rear,          &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(3, 1) }&lt;br /&gt;
spriteset (set_icm_middle,        &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_4_views(4)    }&lt;br /&gt;
spriteset (set_icm_purchase,      &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(5, 53, 14, -25, -10) }&lt;br /&gt;
spriteset (set_icm_invisible,     &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(6,  1,  1,   0,   0) }&lt;br /&gt;
&lt;br /&gt;
/* --- Graphics callback  --- */&lt;br /&gt;
&lt;br /&gt;
/* In the 3-part version, the 3rd car is invisible */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics_middle, ((position_in_consist % 4) == 2) &amp;amp;&amp;amp; (cargo_subtype == 0)) {&lt;br /&gt;
    1: set_icm_invisible;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 4) {&lt;br /&gt;
    0:      set_icm_front_lighted;&lt;br /&gt;
    3:      set_icm_rear_lighted;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Cargo subtype text --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_cargo_subtype_text, cargo_subtype) {&lt;br /&gt;
    0: return string(STR_ICM_SUBTYPE_3_PART);&lt;br /&gt;
    1: return string(STR_ICM_SUBTYPE_4_PART);&lt;br /&gt;
    return CB_RESULT_NO_TEXT;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Articulated part callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add three articulated parts, for a total of four */&lt;br /&gt;
    1 .. 3: return item_icm;&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Start/stop callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12-16 cars) */&lt;br /&gt;
    1 .. 16: return CB_RESULT_NO_TEXT;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Wagon attach callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_can_attach_wagon, vehicle_type_id) {&lt;br /&gt;
    /* SELF refers to the wagon here, check that it&#039;s an ICM */&lt;br /&gt;
    item_icm: return CB_RESULT_ATTACH_ALLOW;&lt;br /&gt;
    return string(STR_ICM_CANNOT_ATTACH_OTHER);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Shorten vehicle callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_3_part_vehicle, position_in_consist % 4) {&lt;br /&gt;
    /* In the three part version, shorten the 2nd vehicle to 7/8 and the 3rd to 1/8&lt;br /&gt;
     * The rear (1/8) part is then made invisisble */&lt;br /&gt;
    1: return SHORTEN_TO_7_8;&lt;br /&gt;
    2: return SHORTEN_TO_1_8;&lt;br /&gt;
    return SHORTEN_TO_8_8;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_shorten_vehicle, cargo_subtype) {&lt;br /&gt;
    0: sw_icm_shorten_3_part_vehicle;&lt;br /&gt;
    return SHORTEN_TO_8_8; // 4-part vehicle needs no shortening&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Power, weight and TE are all applied to the front vehicle only */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_power, cargo_subtype) {&lt;br /&gt;
    0: return int(1260 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
    return int(1890 / 0.7457); // kW -&amp;gt; hp&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_weight, cargo_subtype) {&lt;br /&gt;
    0: return 144; //ton, 3 part train&lt;br /&gt;
    return 192; //ton, 4 part train&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_te, cargo_subtype) {&lt;br /&gt;
    /* Base TE coefficient = 0.3&lt;br /&gt;
     * 3 parts: 4/12 of weight on driving wheels&lt;br /&gt;
     * 4 parts: 6/16 of weight on driving wheels */&lt;br /&gt;
    0: return int(0.3 * 255 / 3);&lt;br /&gt;
    return int(0.3 * 255 * 3 / 8);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the actual train */&lt;br /&gt;
item(FEAT_TRAINS, item_icm) {&lt;br /&gt;
    /* Define properties first, make sure to set all of them */&lt;br /&gt;
    property {&lt;br /&gt;
        name:                         string(STR_ICM_NAME);&lt;br /&gt;
        // not available in toyland:&lt;br /&gt;
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); &lt;br /&gt;
        introduction_date:            date(1983, 1, 1);&lt;br /&gt;
        model_life:                   VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        vehicle_life:                 30;&lt;br /&gt;
        reliability_decay:            20;&lt;br /&gt;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);&lt;br /&gt;
        non_refittable_cargo_classes: bitmask();&lt;br /&gt;
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling&lt;br /&gt;
        // It&#039;s an intercity train, loading is relatively slow:&lt;br /&gt;
        loading_speed:                6; &lt;br /&gt;
        cost_factor:                  45;&lt;br /&gt;
        running_cost_factor:          100; // Changed by callback&lt;br /&gt;
        sprite_id:                    SPRITE_ID_NEW_TRAIN;&lt;br /&gt;
        speed:                        141 km/h; // actually 140, but there are rounding errors&lt;br /&gt;
        misc_flags:                   bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);&lt;br /&gt;
        refit_cost:                   0; //refit costs don&#039;t apply to subcargo display &lt;br /&gt;
        // callback flags are not set manually&lt;br /&gt;
        track_type:                   ELRL; // from rail type table&lt;br /&gt;
        ai_special_flag:              AI_FLAG_PASSENGER;&lt;br /&gt;
        power:                        1260 kW; // Changed by CB&lt;br /&gt;
        running_cost_base:            RUNNING_COST_ELECTRIC;&lt;br /&gt;
        dual_headed:                  0;&lt;br /&gt;
        cargo_capacity:               36; // per part, changed by callback&lt;br /&gt;
        weight:                       144 ton; // Total, changed by callback&lt;br /&gt;
        ai_engine_rank:               0; // not intended to be used by the ai&lt;br /&gt;
        engine_class:                 ENGINE_CLASS_ELECTRIC;&lt;br /&gt;
        extra_power_per_wagon:        0 kW;&lt;br /&gt;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:&lt;br /&gt;
        tractive_effort_coefficient:  0.3 / 3; // changed by callback&lt;br /&gt;
        air_drag_coefficient:         0.06;&lt;br /&gt;
        shorten_vehicle:              SHORTEN_TO_8_8;&lt;br /&gt;
        // Overridden by callback to disable for non-powered wagons:&lt;br /&gt;
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);&lt;br /&gt;
        extra_weight_per_wagon:       0 ton;&lt;br /&gt;
        bitmask_vehicle_info:         0;&lt;br /&gt;
    }&lt;br /&gt;
    /* Define graphics and callbacks&lt;br /&gt;
     * Setting all callbacks is not needed, only define what is used */&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:                      sw_icm_graphics;&lt;br /&gt;
        purchase:                     set_icm_purchase;&lt;br /&gt;
        cargo_subtype_text:           sw_icm_cargo_subtype_text;&lt;br /&gt;
        additional_text:              return string(STR_ICM_ADDITIONAL_TEXT);&lt;br /&gt;
        start_stop:                   sw_icm_start_stop;&lt;br /&gt;
        articulated_part:             sw_icm_articulated_part;&lt;br /&gt;
        can_attach_wagon:             sw_icm_can_attach_wagon;&lt;br /&gt;
        running_cost_factor:          return (cargo_subtype == 1) ? 150 : 100;&lt;br /&gt;
        /* Capacity is per part */&lt;br /&gt;
        cargo_capacity:               return (cargo_subtype == 0) &amp;amp;&amp;amp; ((position_in_consist % 4) == 2) ? 0 : 36;&lt;br /&gt;
        /* In the purchase menu, we want to show the capacity for the three-part version,&lt;br /&gt;
         * i.e. divide the capacity of three cars across four */&lt;br /&gt;
        purchase_cargo_capacity:      return 36 * 3 / 4;&lt;br /&gt;
        /* Only the front vehicle has a visual effect */&lt;br /&gt;
        shorten_vehicle:              sw_icm_shorten_vehicle;&lt;br /&gt;
        /* Only the front vehicle has power */&lt;br /&gt;
        power:                        sw_icm_power;&lt;br /&gt;
        /* Only the front vehicle has weight */&lt;br /&gt;
        weight:                       sw_icm_weight;&lt;br /&gt;
        /* Only the front vehicle has TE */&lt;br /&gt;
        tractive_effort_coefficient:  sw_icm_te;&lt;br /&gt;
        /* Only 1/3 of the weight is on the driving weels. */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language file so far ===&lt;br /&gt;
english.lng now contains this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
&lt;br /&gt;
STR_GRF_NAME                 :NML Example NewGRF: Train&lt;br /&gt;
STR_GRF_DESC                 :{ORANGE}NML Example NewGRF: Train{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}Purno, {BLACK}coding by {SILVER}DJNekkid.{}{BLACK}This NewGRF defines a Dutch EMU, the ICM &#039;Koploper&#039;.&lt;br /&gt;
&lt;br /&gt;
STR_ICM_NAME                 :ICM &#039;Koploper&#039; (Electric)&lt;br /&gt;
STR_ICM_ADDITIONAL_TEXT      :Choose between 3- and 4-part EMU via refit{}Stated values are for the 3-part variant, the 4-part version has 33% more capacity and 50% more power and running cost.&lt;br /&gt;
STR_ICM_SUBTYPE_3_PART       : (3 parts)&lt;br /&gt;
STR_ICM_SUBTYPE_4_PART       : (4 parts)&lt;br /&gt;
STR_ICM_CANNOT_START         :... train too long (max. 4 coupled EMUs).&lt;br /&gt;
STR_ICM_CANNOT_ATTACH_OTHER  :... only other ICMs can be attached to ICM.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you like, this train is done. If you like to continue, you can learn about GRF parameters and then we&#039;ll add a parameter setting to display this train in either 1cc, 2cc or real life colours.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Train three part articulated|Parameters}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_three_part_articulated&amp;diff=8336</id>
		<title>NMLTutorial/Train three part articulated</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_three_part_articulated&amp;diff=8336"/>
		<updated>2012-05-03T16:37:58Z</updated>

		<summary type="html">&lt;p&gt;FooBar: remove refittable_cargo_types&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the [http://dev.openttdcoop.org/projects/nml/repository/show/examples NML source]. The code for this was originally written in NFO by DJNekkid for the 2cc Trainset and rewritten in NML by Hirundo. The graphics used in the example are by Purno. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues the [[NMLTutorial/Train single engine|second part]] of the train example. The train will be made into an articulated EMU that can be purchased all at once.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Callbacks ==&lt;br /&gt;
Except the articulated vehicle callback, we&#039;ll add two more callbacks to only allow attaching more of these multiple units (and not other trains/wagons) and to give the train a maximum length.&lt;br /&gt;
&lt;br /&gt;
The callbacks and switch blocks that are needed for this will be discussed below. What callbacks are available for vehicles can be found in the [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_callbacks NML Documentation]. From here you can decide what callbacks suit your needs and find their names to be used in the graphics block.&lt;br /&gt;
&lt;br /&gt;
=== Articulated part callback ===&lt;br /&gt;
We have seen this one before in the tram example. Returning a single value is not enough for this callback, so we need to reference a switch block to handle the callback.&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        articulated_part:             sw_icm_articulated_part;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callback needs to return the identifier of a vehicle for as long as you want to keep adding parts and return &amp;lt;code&amp;gt;CB_RESULT_NO_MORE_ARTICULATED_PARTS&amp;lt;/code&amp;gt; to stop the process. During the callback the game will continuously call the callback, each time increasing the &amp;lt;code&amp;gt;extra_callback_info1&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:General variable] by one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add two articulated parts, for a total of three */&lt;br /&gt;
    1 .. 2: return item_icm;&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This causes the callback to be called three times, adding two extra parts to the &amp;lt;code&amp;gt;item_icm&amp;lt;/code&amp;gt; vehicle. For an extended explanation of this, see the tram example.&lt;br /&gt;
&lt;br /&gt;
=== Start/stop callback ===&lt;br /&gt;
The start/stop callback is called whenever a vehicle is started in the depot and decides if the vehicle may leave the depot. The callback must return &amp;lt;code&amp;gt;CB_RESULT_NO_TEXT&amp;lt;/code&amp;gt; to allow the vehicle to leave the depot. If you want to prevent the vehicle from leaving the depot, the callback must return a string containing an error message.&lt;br /&gt;
&lt;br /&gt;
We want to use this callback to check the vehicle length. As such it makes sense to base the decision on the length of the train, which can be found using the &amp;lt;code&amp;gt;num_vehs_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable]. Because we need to base a decision on some variable, we&#039;ll use a switch block to do that.&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        start_stop:                   sw_icm_start_stop;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We want to limit our train length to a maximum of four coupled EMUs. As each EMU has a length of three, the total possible train length is twelve. So for train lengths 1 to 12 we want to return &amp;lt;code&amp;gt;CB_RESULT_NO_TEXT&amp;lt;/code&amp;gt; (and allow the train to leave the depot). For any other train length we return a string to disallow starting the train and informing the user why that is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12 cars) */&lt;br /&gt;
    1 .. 12: return CB_RESULT_NO_TEXT;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we added a new string, define it in the language file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
STR_ICM_CANNOT_START         :... train too long (max. 4 coupled EMUs).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Wagon attach callback ===&lt;br /&gt;
We only want to allow attaching more of the same EMUs to this train. Amongst others, the callback can return a custom string to disallow or return &amp;lt;code&amp;gt;CB_RESULT_ATTACH_ALLOW&amp;lt;/code&amp;gt; to allow attaching. The decision must be made on the basis of the identifier of the wagon that is being attached. We can use the &amp;lt;code&amp;gt;vehicle_type_id&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] to make that decision, using a switch block.&lt;br /&gt;
&lt;br /&gt;
Add to the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        can_attach_wagon:             sw_icm_can_attach_wagon;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will be the switch block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_can_attach_wagon, vehicle_type_id) {&lt;br /&gt;
    /* SELF refers to the wagon here, check that it&#039;s an ICM */&lt;br /&gt;
    item_icm: return CB_RESULT_ATTACH_ALLOW;&lt;br /&gt;
    return string(STR_ICM_CANNOT_ATTACH_OTHER);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the attached wagon is of the type &#039;&#039;item_icm&#039;&#039;, it is allowed. Otherwise, a custom error message is displayed. This obviously means that we have to add this message to the language file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
STR_ICM_CANNOT_ATTACH_OTHER  :... only other ICMs can be attached to ICM.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
The final step in making this work is adding the graphics for the second and third part of the train. This is the same as in the tram example: point to a switch from the graphics block, make a decision based on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Vehicle_variables variable] and point to the spritesets from there.&lt;br /&gt;
&lt;br /&gt;
We already have the graphics and spritesets defined, so that&#039;s no problem.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 3) {&lt;br /&gt;
    0:      set_icm_front_lighted;&lt;br /&gt;
    2:      set_icm_rear_lighted;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This particular switch block actually first does a calculation on the &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; variable before making a decision on the result of that calculation. Here the modulo 3 of the value of &amp;lt;code&amp;gt;position_in_consist&amp;lt;/code&amp;gt; is calculated (&amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; is the modulo operator, see [http://en.wikipedia.org/wiki/Modulo_operation Wikipedia] for more details on modulo but basically it&#039;s the remainder after devision (by three in this case)).&lt;br /&gt;
&lt;br /&gt;
So for the first three vehicle parts the expression will yield 0, 1 and 2. For part four through six, it will again yield 0, 1 and 2, etc. The callback decision is then made on these three values alone: for part 0 use graphics for the train front, for part 2 use graphics for the train end and for all other parts use graphics for the middle.&lt;br /&gt;
&lt;br /&gt;
Also don&#039;t forget to reference this switch instead of the spriteset directly from the graphics block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        default:                      sw_icm_graphics;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purchase menu sprite ==&lt;br /&gt;
The spriteset for the purchase menu sprite is already there. We only need to reference it from the graphics block&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
        purchase:                     set_icm_purchase;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Total code so far ==&lt;br /&gt;
When put in the correct order, this should now encode as a working NewGRF. The total code so far:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
/* Define grf */&lt;br /&gt;
grf {&lt;br /&gt;
    grfid: &amp;quot;NML\00&amp;quot;;&lt;br /&gt;
    /* GRF name and description strings are defined in the lang files */&lt;br /&gt;
    name: string(STR_GRF_NAME);&lt;br /&gt;
    desc: string(STR_GRF_DESC);&lt;br /&gt;
    /* This is the first version, start numbering at 0. */&lt;br /&gt;
    version: 0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define a rail type table,&lt;br /&gt;
 * this allows referring to railtypes&lt;br /&gt;
 * irrespective of the grfs loaded.&lt;br /&gt;
 */&lt;br /&gt;
railtypetable {&lt;br /&gt;
    RAIL, ELRL, MONO, MGLV,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Basic template for 4 vehicle views */&lt;br /&gt;
template tmpl_vehicle_basic(x, y) {&lt;br /&gt;
    // arguments x, y: coordinates of top-left corner of first sprite&lt;br /&gt;
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xrel yrel&lt;br /&gt;
    [x +  9, y, 22, 20, -14, -12]&lt;br /&gt;
    [x + 32, y, 32, 16, -16, -12]&lt;br /&gt;
    [x + 65, y, 22, 20,  -6, -12]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with only 4 views (symmetric) */&lt;br /&gt;
template tmpl_vehicle_4_views(num) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    tmpl_vehicle_basic(1, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with 8 views (non-symmetric) */&lt;br /&gt;
template tmpl_vehicle_8_views(num, reversed) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    // argument reversed: Reverse visible orientation of vehicle, if set to 1&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a single vehicle sprite */&lt;br /&gt;
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {&lt;br /&gt;
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the spritesets, these allow referring to these sprites later on */&lt;br /&gt;
spriteset (set_icm_front_lighted, &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(0, 0) }&lt;br /&gt;
spriteset (set_icm_rear_lighted,  &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(1, 1) }&lt;br /&gt;
spriteset (set_icm_front,         &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(2, 0) }&lt;br /&gt;
spriteset (set_icm_rear,          &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(3, 1) }&lt;br /&gt;
spriteset (set_icm_middle,        &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_4_views(4)    }&lt;br /&gt;
spriteset (set_icm_purchase,      &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(5, 53, 14, -25, -10) }&lt;br /&gt;
spriteset (set_icm_invisible,     &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(6,  1,  1,   0,   0) }&lt;br /&gt;
&lt;br /&gt;
/* Choose between front, middle and back parts */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_graphics, position_in_consist % 3) {&lt;br /&gt;
    0:      set_icm_front_lighted;&lt;br /&gt;
    2:      set_icm_rear_lighted;&lt;br /&gt;
    set_icm_middle;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Articulated part callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_articulated_part, extra_callback_info1) {&lt;br /&gt;
    /* Add three articulated parts, for a total of four */&lt;br /&gt;
    1 .. 2: return item_icm;&lt;br /&gt;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Start/stop callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_start_stop, num_vehs_in_consist) {&lt;br /&gt;
    /* Vehicles may be coupled to a maximum of 4 units (12 cars) */&lt;br /&gt;
    1 .. 12: return CB_RESULT_NO_TEXT;&lt;br /&gt;
    return string(STR_ICM_CANNOT_START);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* --- Wagon attach callback  --- */&lt;br /&gt;
switch(FEAT_TRAINS, SELF, sw_icm_can_attach_wagon, vehicle_type_id) {&lt;br /&gt;
    /* SELF refers to the wagon here, check that it&#039;s an ICM */&lt;br /&gt;
    item_icm: return CB_RESULT_ATTACH_ALLOW;&lt;br /&gt;
    return string(STR_ICM_CANNOT_ATTACH_OTHER);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the actual train */&lt;br /&gt;
item(FEAT_TRAINS, item_icm) {&lt;br /&gt;
    /* Define properties first, make sure to set all of them */&lt;br /&gt;
    property {&lt;br /&gt;
        name:                         string(STR_ICM_NAME);&lt;br /&gt;
        // not available in toyland:&lt;br /&gt;
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); &lt;br /&gt;
        introduction_date:            date(1983, 1, 1);&lt;br /&gt;
        model_life:                   VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        vehicle_life:                 30;&lt;br /&gt;
        reliability_decay:            20;&lt;br /&gt;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);&lt;br /&gt;
        non_refittable_cargo_classes: bitmask();&lt;br /&gt;
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling&lt;br /&gt;
        // It&#039;s an intercity train, loading is relatively slow:&lt;br /&gt;
        loading_speed:                6; &lt;br /&gt;
        cost_factor:                  45;&lt;br /&gt;
        running_cost_factor:          100; // Changed by callback&lt;br /&gt;
        sprite_id:                    SPRITE_ID_NEW_TRAIN;&lt;br /&gt;
        speed:                        141 km/h; // actually 140, but there are rounding errors&lt;br /&gt;
        misc_flags:                   bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);&lt;br /&gt;
        refit_cost:                   0; //refit costs don&#039;t apply to subcargo display &lt;br /&gt;
        // callback flags are not set manually&lt;br /&gt;
        track_type:                   ELRL; // from rail type table&lt;br /&gt;
        ai_special_flag:              AI_FLAG_PASSENGER;&lt;br /&gt;
        power:                        1260 kW; // Changed by CB&lt;br /&gt;
        running_cost_base:            RUNNING_COST_ELECTRIC;&lt;br /&gt;
        dual_headed:                  0;&lt;br /&gt;
        cargo_capacity:               36; // per part, changed by callback&lt;br /&gt;
        weight:                       144 ton; // Total, changed by callback&lt;br /&gt;
        ai_engine_rank:               0; // not intended to be used by the ai&lt;br /&gt;
        engine_class:                 ENGINE_CLASS_ELECTRIC;&lt;br /&gt;
        extra_power_per_wagon:        0 kW;&lt;br /&gt;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:&lt;br /&gt;
        tractive_effort_coefficient:  0.3 / 3; // changed by callback&lt;br /&gt;
        air_drag_coefficient:         0.06;&lt;br /&gt;
        shorten_vehicle:              SHORTEN_TO_8_8;&lt;br /&gt;
        // Overridden by callback to disable for non-powered wagons:&lt;br /&gt;
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);&lt;br /&gt;
        extra_weight_per_wagon:       0 ton;&lt;br /&gt;
        bitmask_vehicle_info:         0;&lt;br /&gt;
    }&lt;br /&gt;
    /* Define graphics and callbacks&lt;br /&gt;
     * Setting all callbacks is not needed, only define what is used */&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:                      sw_icm_graphics;&lt;br /&gt;
        purchase:                     set_icm_purchase;&lt;br /&gt;
        start_stop:                   sw_icm_start_stop;&lt;br /&gt;
        articulated_part:             sw_icm_articulated_part;&lt;br /&gt;
        can_attach_wagon:             sw_icm_can_attach_wagon;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language file so far ===&lt;br /&gt;
english.lng now contains this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
&lt;br /&gt;
STR_GRF_NAME                 :NML Example NewGRF: Train&lt;br /&gt;
STR_GRF_DESC                 :{ORANGE}NML Example NewGRF: Train{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}Purno, {BLACK}coding by {SILVER}DJNekkid.{}{BLACK}This NewGRF defines a Dutch EMU, the ICM &#039;Koploper&#039;.&lt;br /&gt;
&lt;br /&gt;
STR_ICM_NAME                 :ICM &#039;Koploper&#039; (Electric)&lt;br /&gt;
STR_ICM_CANNOT_START         :... train too long (max. 4 coupled EMUs).&lt;br /&gt;
STR_ICM_CANNOT_ATTACH_OTHER  :... only other ICMs can be attached to ICM.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is now a working 3-part EMU. In real life, the EMU is also available as a 4-part variant. In the next part of the tutorial, we will add the option to choose between a 3- and 4 part EMU via a refit.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Train single engine|Train four part refit}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_single_engine&amp;diff=8335</id>
		<title>NMLTutorial/Train single engine</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Train_single_engine&amp;diff=8335"/>
		<updated>2012-05-03T16:37:28Z</updated>

		<summary type="html">&lt;p&gt;FooBar: remove refittable_cargo_types&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&#039;&#039;The example used here is from the [http://dev.openttdcoop.org/projects/nml/repository/show/examples NML source]. The code for this was originally written in NFO by DJNekkid for the 2cc Trainset and rewritten in NML by Hirundo. The graphics used in the example are by Purno. Code and graphics are both licensed according to the GPL v2 or later. The code has been modified for the purpose of this tutorial&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This continues the [[NMLTutorial/Train|first part]] of the train example. On this page we&#039;ll make a single engined train.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Item block ==&lt;br /&gt;
The first step towards a train is defining an item block for it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Define the actual train */&lt;br /&gt;
item(FEAT_TRAINS, item_icm) {&lt;br /&gt;
    /* Define properties first, make sure to set all of them */&lt;br /&gt;
    property {&lt;br /&gt;
        name:                         string(STR_ICM_NAME);&lt;br /&gt;
        // not available in toyland:&lt;br /&gt;
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); &lt;br /&gt;
        introduction_date:            date(1983, 1, 1);&lt;br /&gt;
        model_life:                   VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        vehicle_life:                 30;&lt;br /&gt;
        reliability_decay:            20;&lt;br /&gt;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);&lt;br /&gt;
        non_refittable_cargo_classes: bitmask();&lt;br /&gt;
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling&lt;br /&gt;
        // It&#039;s an intercity train, loading is relatively slow:&lt;br /&gt;
        loading_speed:                6; &lt;br /&gt;
        cost_factor:                  45;&lt;br /&gt;
        running_cost_factor:          100; // Changed by callback&lt;br /&gt;
        sprite_id:                    SPRITE_ID_NEW_TRAIN;&lt;br /&gt;
        speed:                        141 km/h; // actually 140, but there are rounding errors&lt;br /&gt;
        misc_flags:                   bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);&lt;br /&gt;
        refit_cost:                   0; //refit costs don&#039;t apply to subcargo display &lt;br /&gt;
        // callback flags are not set manually&lt;br /&gt;
        track_type:                   ELRL; // from rail type table&lt;br /&gt;
        ai_special_flag:              AI_FLAG_PASSENGER;&lt;br /&gt;
        power:                        1260 kW; // Changed by CB&lt;br /&gt;
        running_cost_base:            RUNNING_COST_ELECTRIC;&lt;br /&gt;
        dual_headed:                  0;&lt;br /&gt;
        cargo_capacity:               36; // per part, changed by callback&lt;br /&gt;
        weight:                       144 ton; // Total, changed by callback&lt;br /&gt;
        ai_engine_rank:               0; // not intended to be used by the ai&lt;br /&gt;
        engine_class:                 ENGINE_CLASS_ELECTRIC;&lt;br /&gt;
        extra_power_per_wagon:        0 kW;&lt;br /&gt;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:&lt;br /&gt;
        tractive_effort_coefficient:  0.3 / 3; // changed by callback&lt;br /&gt;
        air_drag_coefficient:         0.06;&lt;br /&gt;
        shorten_vehicle:              SHORTEN_TO_8_8;&lt;br /&gt;
        // Overridden by callback to disable for non-powered wagons:&lt;br /&gt;
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);&lt;br /&gt;
        extra_weight_per_wagon:       0 ton;&lt;br /&gt;
        bitmask_vehicle_info:         0;&lt;br /&gt;
    }&lt;br /&gt;
    /* Define graphics and callbacks&lt;br /&gt;
     * Setting all callbacks is not needed, only define what is used */&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:                      set_icm_front_lighted;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The property block is again a list with properties for this vehicle. You can look the available properties up in the [http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles#Properties_common_to_all_vehicle_types NML Documentation]. The properties are self-explanatory with a little help from their descriptions in the NML Documentation. Properties that have a comment that they will be changed by a callback actually need not be changed by a callback for the single engined train, these callbacks are only relevant for when we get to refitting the train in a three and four part version.&lt;br /&gt;
&lt;br /&gt;
From the graphics block we&#039;ll add the default sprites for this vehicle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Language file ==&lt;br /&gt;
The properties block references one string (the vehicle name), which of course must be added to the language file. Open the language file and add the string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
STR_ICM_NAME                 :ICM &#039;Koploper&#039; (Electric)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Railtype table ==&lt;br /&gt;
For the &amp;lt;code&amp;gt;track_type&amp;lt;/code&amp;gt; we&#039;ve used the &amp;lt;code&amp;gt;ELRL&amp;lt;/code&amp;gt; railtype label. Apart from the fact that this is not available by default, we want our train to be working regardless of the track sets loaded in OpenTTD. This means adding a railtype table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
railtypetable {&lt;br /&gt;
    ELRL&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We only use one railtype label, so that&#039;s really all we need in the railtypetable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
Below you&#039;ll find the complete graphics file that will be used throughout the example. For now we&#039;ll only use the first block of eight sprites for the vehicle, but define templates and spritesets for all others while we&#039;re at it.&lt;br /&gt;
&lt;br /&gt;
[[Image:Icm.png|frame|none|Dutch ICM &#039;Koploper&#039; sprites. Drawn by Purno.]]&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
This example will show you some advanced tricks that you can use with templates. Of course you&#039;re free to use more simple templates like those used in the road vehicle and tram examples. In total this example defines four templates for all sprite uses (including those that will be added later) and uses templates inside templates (yes, that&#039;s possible). &lt;br /&gt;
&lt;br /&gt;
Below each template will be introduced and explained.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Basic template for 4 vehicle views */&lt;br /&gt;
template tmpl_vehicle_basic(x, y) {&lt;br /&gt;
    // arguments x, y: coordinates of top-left corner of first sprite&lt;br /&gt;
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xoff yoff&lt;br /&gt;
    [x +  9, y, 22, 20, -14, -12]&lt;br /&gt;
    [x + 32, y, 32, 16, -16, -12]&lt;br /&gt;
    [x + 65, y, 22, 20,  -6, -12]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The template above is a normal template as we&#039;ve seen those before. Arguments are used for the top-left corner of the first sprite. Nothing fancy here, except that only four sprites are listed and we need eight.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Template for a vehicle with only 4 views (symmetric) */&lt;br /&gt;
template tmpl_vehicle_4_views(num) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    tmpl_vehicle_basic(1, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This template includes the previous templated and is intended to be used for blocks of four sprites, like the passenger carriage in the image above. This template takes one argument where you set in which row of the graphics file to find the sprites. NML then calculates the actual values for x and y that the included template needs. The value for x in this case is a constant 1, as each block of sprites in the graphics file starts one pixel from the left. The distance from the top is calculated: each block of sprites is 32 pixels apart and the first block starts one pixel from the top. So with the number of the row as input argument, the calculation is to multiply this input by 32 and add 1. This gives the correct value for y.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Template for a vehicle with 8 views (non-symmetric) */&lt;br /&gt;
template tmpl_vehicle_8_views(num, reversed) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    // argument reversed: Reverse visible orientation of vehicle, if set to 1&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This template also includes the first template and uses a same argument for the row number as the previous template. This argument is again used to calculate the value of y for the first template. The first template is included twice, which means it&#039;s intended for blocks of eight sprites.&lt;br /&gt;
&lt;br /&gt;
The template also takes a second argument, which adds a trick to swap the first four and last four sprites. If the argument is set to 1, the last four sprites are included first and the first four second. If it&#039;s set to any other value, the normal sprite order is used for the eight sprites. That way a spriteset for a reversed vehicle can be created. This argument is used to calculate the value of x by means of a [http://en.wikipedia.org/wiki/%3F:#Conditional_assignment conditional assignment]. How this works is that the expression in front of the ? is evaluated to true or false. If the expression returns true, the value between the ? and : is used. If the expression returns false the value after the : is used.&lt;br /&gt;
&lt;br /&gt;
A value of 1 in this case is equal to true. Then a value for x of 89 is used for the first included template, otherwise value 1 is used for x. The same reasoning applies to the second included template, but of course the other way round.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Template for a single vehicle sprite */&lt;br /&gt;
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {&lt;br /&gt;
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This last template has arguments for almost everything, so sprite size and offsets must be set every time this template is used. Only the distance from the top is calculated using the row number (like in the previous two templates) and the distance from the left is again a constant 1.&lt;br /&gt;
&lt;br /&gt;
=== Spritesets ===&lt;br /&gt;
With these templates, spritesets can be defined:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
/* Define the spritesets, these allow referring to these sprites later on */&lt;br /&gt;
spriteset (set_icm_front_lighted, &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(0, 0) }&lt;br /&gt;
spriteset (set_icm_rear_lighted,  &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(1, 1) }&lt;br /&gt;
spriteset (set_icm_front,         &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(2, 0) }&lt;br /&gt;
spriteset (set_icm_rear,          &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(3, 1) }&lt;br /&gt;
spriteset (set_icm_middle,        &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_4_views(4)    }&lt;br /&gt;
spriteset (set_icm_purchase,      &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(5, 53, 14, -25, -10) }&lt;br /&gt;
spriteset (set_icm_invisible,     &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(6,  1,  1,   0,   0) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first and third spriteset are for the front of the EMU, with and without lights. The template for eight sprites, unreversed, is used for these two spritesets.&lt;br /&gt;
The second and fourth spriteset are similar, this time for the back of the EMU, using the same template but this time reversed.&lt;br /&gt;
The fifth spriteset is for the middle parts of the EMU, the wagons if you like, only using the template for four sprites.&lt;br /&gt;
The sixth spriteset is for the purchase menu sprite, using the last template setting the fifth row and manual values for size and offsets.&lt;br /&gt;
The last spriteset is a single transparent pixel sprite, which will be used to hide one of the middle parts when we get to adding the four part refit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the single engine we now only use the &amp;lt;code&amp;gt;set_icm_front_lighted&amp;lt;/code&amp;gt; spriteset. It is already referenced from the graphics block. This will also be used for the purchase menu, which is fine for non-articulated trains and road vehicles. If you want to encode this intermediate result, you best remove the other spritesets or comment them out (as is done for the total code so far below).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Total code so far ==&lt;br /&gt;
When put in the correct order, this should now encode as a working NewGRF. The total code so far:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
/* Define grf */&lt;br /&gt;
grf {&lt;br /&gt;
    grfid: &amp;quot;NML\00&amp;quot;;&lt;br /&gt;
    /* GRF name and description strings are defined in the lang files */&lt;br /&gt;
    name: string(STR_GRF_NAME);&lt;br /&gt;
    desc: string(STR_GRF_DESC);&lt;br /&gt;
    /* This is the first version, start numbering at 0. */&lt;br /&gt;
    version: 0;&lt;br /&gt;
    min_compatible_version: 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define a rail type table,&lt;br /&gt;
 * this allows referring to railtypes&lt;br /&gt;
 * irrespective of the grfs loaded.&lt;br /&gt;
 */&lt;br /&gt;
railtypetable {&lt;br /&gt;
    RAIL, ELRL, MONO, MGLV,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Basic template for 4 vehicle views */&lt;br /&gt;
template tmpl_vehicle_basic(x, y) {&lt;br /&gt;
    // arguments x, y: coordinates of top-left corner of first sprite&lt;br /&gt;
    [x,      y,  8, 24,  -3, -12] //xpos ypos xsize ysize xrel yrel&lt;br /&gt;
    [x +  9, y, 22, 20, -14, -12]&lt;br /&gt;
    [x + 32, y, 32, 16, -16, -12]&lt;br /&gt;
    [x + 65, y, 22, 20,  -6, -12]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with only 4 views (symmetric) */&lt;br /&gt;
template tmpl_vehicle_4_views(num) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    tmpl_vehicle_basic(1, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a vehicle with 8 views (non-symmetric) */&lt;br /&gt;
template tmpl_vehicle_8_views(num, reversed) {&lt;br /&gt;
    // argument num: Index in the graphics file, assuming vertical ordering of vehicles&lt;br /&gt;
    // argument reversed: Reverse visible orientation of vehicle, if set to 1&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 89 : 1, 1 + 32 * num)&lt;br /&gt;
    tmpl_vehicle_basic(reversed ? 1 : 89, 1 + 32 * num)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Template for a single vehicle sprite */&lt;br /&gt;
template tmpl_vehicle_single(num, xsize, ysize, xoff, yoff) {&lt;br /&gt;
    [1, 1 + 32 * num, xsize, ysize, xoff, yoff]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Define the spritesets, these allow referring to these sprites later on */&lt;br /&gt;
spriteset (set_icm_front_lighted, &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(0, 0) }&lt;br /&gt;
spriteset (set_icm_rear_lighted,  &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(1, 1) }&lt;br /&gt;
spriteset (set_icm_front,         &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(2, 0) }&lt;br /&gt;
spriteset (set_icm_rear,          &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_8_views(3, 1) }&lt;br /&gt;
spriteset (set_icm_middle,        &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_4_views(4)    }&lt;br /&gt;
spriteset (set_icm_purchase,      &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(5, 53, 14, -25, -10) }&lt;br /&gt;
spriteset (set_icm_invisible,     &amp;quot;gfx/icm.png&amp;quot;) { tmpl_vehicle_single(6,  1,  1,   0,   0) }&lt;br /&gt;
&lt;br /&gt;
/* Define the actual train */&lt;br /&gt;
item(FEAT_TRAINS, item_icm) {&lt;br /&gt;
    /* Define properties first, make sure to set all of them */&lt;br /&gt;
    property {&lt;br /&gt;
        name:                         string(STR_ICM_NAME);&lt;br /&gt;
        // not available in toyland:&lt;br /&gt;
        climates_available:           bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); &lt;br /&gt;
        introduction_date:            date(1983, 1, 1);&lt;br /&gt;
        model_life:                   VEHICLE_NEVER_EXPIRES;&lt;br /&gt;
        vehicle_life:                 30;&lt;br /&gt;
        reliability_decay:            20;&lt;br /&gt;
        refittable_cargo_classes:     bitmask(CC_PASSENGERS);&lt;br /&gt;
        non_refittable_cargo_classes: bitmask();&lt;br /&gt;
        // refitting is done via cargo classes only, no cargo types need explicit enabling/disabling&lt;br /&gt;
        // It&#039;s an intercity train, loading is relatively slow:&lt;br /&gt;
        loading_speed:                6; &lt;br /&gt;
        cost_factor:                  45;&lt;br /&gt;
        running_cost_factor:          100; // Changed by callback&lt;br /&gt;
        sprite_id:                    SPRITE_ID_NEW_TRAIN;&lt;br /&gt;
        speed:                        141 km/h; // actually 140, but there are rounding errors&lt;br /&gt;
        misc_flags:                   bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_MU);&lt;br /&gt;
        refit_cost:                   0; //refit costs don&#039;t apply to subcargo display &lt;br /&gt;
        // callback flags are not set manually&lt;br /&gt;
        track_type:                   ELRL; // from rail type table&lt;br /&gt;
        ai_special_flag:              AI_FLAG_PASSENGER;&lt;br /&gt;
        power:                        1260 kW; // Changed by CB&lt;br /&gt;
        running_cost_base:            RUNNING_COST_ELECTRIC;&lt;br /&gt;
        dual_headed:                  0;&lt;br /&gt;
        cargo_capacity:               36; // per part, changed by callback&lt;br /&gt;
        weight:                       144 ton; // Total, changed by callback&lt;br /&gt;
        ai_engine_rank:               0; // not intended to be used by the ai&lt;br /&gt;
        engine_class:                 ENGINE_CLASS_ELECTRIC;&lt;br /&gt;
        extra_power_per_wagon:        0 kW;&lt;br /&gt;
        // 4/12 of weight on driving wheels, with a default friction coefficient of 0.3:&lt;br /&gt;
        tractive_effort_coefficient:  0.3 / 3; // changed by callback&lt;br /&gt;
        air_drag_coefficient:         0.06;&lt;br /&gt;
        shorten_vehicle:              SHORTEN_TO_8_8;&lt;br /&gt;
        // Overridden by callback to disable for non-powered wagons:&lt;br /&gt;
        visual_effect_and_powered:    visual_effect_and_powered(VISUAL_EFFECT_ELECTRIC, 2, DISABLE_WAGON_POWER);&lt;br /&gt;
        extra_weight_per_wagon:       0 ton;&lt;br /&gt;
        bitmask_vehicle_info:         0;&lt;br /&gt;
    }&lt;br /&gt;
    /* Define graphics and callbacks&lt;br /&gt;
     * Setting all callbacks is not needed, only define what is used */&lt;br /&gt;
    graphics {&lt;br /&gt;
        default:                      set_icm_front_lighted;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language file so far ===&lt;br /&gt;
english.lng now contains this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue; white-space: pre-wrap; max-height: 200px; overflow:scroll&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
&lt;br /&gt;
STR_GRF_NAME                 :NML Example NewGRF: Train&lt;br /&gt;
STR_GRF_DESC                 :{ORANGE}NML Example NewGRF: Train{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}Purno, {BLACK}coding by {SILVER}DJNekkid.{}{BLACK}This NewGRF defines a Dutch EMU, the ICM &#039;Koploper&#039;.&lt;br /&gt;
&lt;br /&gt;
STR_ICM_NAME                 :ICM &#039;Koploper&#039; (Electric)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is now a working train engine, but not an EMU. On the next page we&#039;ll expand the code we have so far to make this train into a proper EMU which can be purchased as prebuilt consist without the need to add wagons yourself.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Train|Train three part articulated}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Cargotable&amp;diff=8334</id>
		<title>NMLTutorial/Cargotable</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Cargotable&amp;diff=8334"/>
		<updated>2012-05-03T16:33:52Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Information on the &amp;#039;new&amp;#039; cargo_(dis)allow_refit properties&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
Whenever you want to work with specific cargos, you need to teach NML about those cargos. The reason for this is that new cargos can be invented at will, so NML doesn&#039;t keep a list of existing cargo labels and therefore you have to provide this list yourself. &amp;lt;!-- This is probably a good enough reason for regular users that NML doesn&#039;t make the cargotable itself. I think it could be made to do that. I don&#039;t have the knowledge to implement that, but it should be possible in my view... --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Cargotable ==&lt;br /&gt;
&lt;br /&gt;
The cargotable is the means to let NML know about the cargo labels you want to use in your NML file. An NML file can have exactly one cargotable. The cargotable needs to be defined before you reference a cargo label in your NML code.&lt;br /&gt;
&lt;br /&gt;
The cargotable itself is no more than a list of cargo labels. You need to [http://newgrf-specs.tt-wiki.net/wiki/CargoTypes#Cargo_Labels look the cargo labels up] for the cargos you want to do special things with. This is what the general syntax looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
cargotable {&lt;br /&gt;
	&amp;lt;cargo_label1&amp;gt; [, &amp;lt;cargo_label2&amp;gt; [, &amp;lt;cargo_label3&amp;gt; ... ]]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add as many cargo labels to the cargotable as you want/need.&lt;br /&gt;
&lt;br /&gt;
=== First 32 cargo labels ===&lt;br /&gt;
[[File:Ttdpatch_icon.png]] When making a vehicle set for TTDPatch, the first 32 cargo labels should be selected with care. The reasons for this is that only the first 32 cargos can be used in the &amp;lt;code&amp;gt;refittable_cargo_types&amp;lt;/code&amp;gt; property for vehicles. So stick cargo labels you use in that property into the cargotable first and add other cargo labels at the end.&lt;br /&gt;
&lt;br /&gt;
[[File:Openttd_icon.png]] If you&#039;re using more advanced features of NewGRF that only work in OpenTTD anyways, the order of labels in the cargotable doesn&#039;t matter. For OpenTTD-only vehicle sets you should not use the &amp;lt;code&amp;gt;refittable_cargo_types&amp;lt;/code&amp;gt; property, but the &amp;lt;code&amp;gt;cargo_allow_refit&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cargo_disallow_refit&amp;lt;/code&amp;gt; properties instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Cargo labels or cargo classes? ==&lt;br /&gt;
When it comes to allowing cargos in a vehicle, you should always use cargo classes and not only cargo labels. That way your vehicle set will be compatible with cargos that don&#039;t even exist yet. &lt;br /&gt;
&lt;br /&gt;
[[File:Ttdpatch_icon.png]] Use cargo labels only to deny or allow specific cargos in your vehicles that don&#039;t match the cargo classes you have set.&lt;br /&gt;
&lt;br /&gt;
[[File:Openttd_icon.png]] For OpenTTD-only vehicle NewGRFs, define all known cargo labels in the &amp;lt;code&amp;gt;cargo_allow_refit&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cargo_disallow_refit&amp;lt;/code&amp;gt; properties and provide the cargo classes additionally to that for compatibility with future cargoes that haven&#039;t been invented yet.&lt;br /&gt;
&lt;br /&gt;
Furthermore, industries and houses don&#039;t work with cargo classes, so there you can only use the cargo labels. Also if you want specific graphics for specific cargoes, you have to use cargo types and not cargo classes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that you know about the cargotable, let&#039;s add some cargo specific graphics to our example road vehicle.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Road vehicle graphics template|Road vehicle cargo graphics}}&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Save_paletted_image_files&amp;diff=8280</id>
		<title>Save paletted image files</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Save_paletted_image_files&amp;diff=8280"/>
		<updated>2012-04-16T18:14:48Z</updated>

		<summary type="html">&lt;p&gt;FooBar: missed one&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This pagecovers how to apply a palette to a graphics file in several graphics editor. If your editor is not listed here and you know how to work with palettes using it, please add it here.&lt;br /&gt;
&lt;br /&gt;
You find a range of palettes with and without action colours (which might be useful for conversions) for various graphics programmes on the [http://dev.openttdcoop.org/documents/1 DevZone]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adobe Photoshop ==&lt;br /&gt;
[[Image:Photoshop palette window with windows ttd palette.png|thumb|50%|Fig. 1: Photoshop palette window showing in this case the Windows palette]]&lt;br /&gt;
[[Image:Photoshop indexed color window.png|thumb|50%|Fig. 2: Photoshop indexed color window]]&lt;br /&gt;
&lt;br /&gt;
In this subsection it is explained how to create a palette file and how to apply it using Adobe Photoshop (CS5 is used here, but identical or similar procedures apply in other versions of Photoshop). It is assumed that you have a clue about working with Photoshop.&lt;br /&gt;
&lt;br /&gt;
=== Retreiving a palette file ===&lt;br /&gt;
You can use an existing graphics file that has the correct palette applied to retrieve the palette and save it to a separate file. This palette can then be applied to graphics files that don&#039;t have a palette. You can skip this part if you have [http://dev.openttdcoop.org/attachments/1749/photoshop-ttd-dos.act downloaded a premade palette file].&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file of which you know it has the correct palette in Photoshop. Decoded NewGRFs (using GRFCodec) surely will have the correct palette applied.&lt;br /&gt;
# Go to Image &amp;gt; Mode &amp;gt; Color Table... The window from Fig. 1 will appear. &lt;br /&gt;
# Click Save... and store the palette file (*.act) somewhere on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Applying a palette from file ===&lt;br /&gt;
The Windows or DOS TTD palette must be applied to your graphics file for them to work in GRFCodec and NML. For the next steps we assume that you have a palette file (*.act) with the palette of your choice stored somewhere on your computer.&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file in Photoshop.&lt;br /&gt;
# Go to Image &amp;gt; Mode and check if RGB Color is checked. Select it if that is not the case, which will convert your graphics file to full-colour, maintaining the colours as they appear.&lt;br /&gt;
# Go to Image &amp;gt; Mode &amp;gt; Indexed Color... The window from Fig. 2 will appear. &lt;br /&gt;
# From the Palette drop-down, select Custom... The palette window (see Fig. 1) appears.&lt;br /&gt;
# Click Load... and browse the palette file. Click OK to close the palette window.&lt;br /&gt;
# In the indexed color window, you may select your choise of Dither. The dither will convert all colours that are in the graphics file but not in the palette to the palette colours. Either use the Diffusion dither (with preserving exact colors) or the Noise dither. Play around with the settings using the Preview to see the result and pick whatever looks best. If the sprites in the image file were drawn properly (using only palette colours), you should see no difference.&lt;br /&gt;
# Click OK to apply the palette file (and dither) to this image file. Note that this will flatten all layers (if any) in your graphics file.&lt;br /&gt;
# Save the file as (preferrably) a PNG image.&lt;br /&gt;
&lt;br /&gt;
=== Important note on PCX files in Photoshop ===&lt;br /&gt;
Photoshop has a quirk in which palettes from PCX files are read and written backwards. This is no problem is you stay with pcx, but it is if you convert from pcx to png (and the other way round). Any such conversion will have the palette stored backwards in the target file, making it unusable by GRFCodec or NML. Note:&lt;br /&gt;
* You cannot use the palette file saved from a PCX file for a PNG file;&lt;br /&gt;
* You cannot use the palette file saved from a PNG file for a PCX file;&lt;br /&gt;
* When converting PCX &amp;lt;-&amp;gt; PNG, you must convert to RGB Color first and then back to Indexed Color, applying the palette file of your target file format (e.g. when converting to PNG, apply the palette retrieved from a PNG file).&lt;br /&gt;
&lt;br /&gt;
== GIMP ==&lt;br /&gt;
[[Image:GIMP palette window.png|thumb|50%|Fig. 3: GIMP palette window]]&lt;br /&gt;
[[Image:GIMP import palette window.png|thumb|50%|Fig. 4: GIMP import pallete window showing the TTD Windows palette]]&lt;br /&gt;
[[Image:GIMP indexed color conversion window.png|thumb|50%|Fig. 5: GIMP indexed color conversion window]]&lt;br /&gt;
&lt;br /&gt;
In this subsection it is explained how to create a palette file and how to apply it using the GNU Image Manipulation Program (2.6 is used here, but identical or similar procedures should apply in other versions). It is assumed that you have a clue about working with GIMP.&lt;br /&gt;
&lt;br /&gt;
=== Download a palette file ===&lt;br /&gt;
In case of doubt you simply want to get the [http://dev.openttdcoop.org/attachments/1741/ttd-newgrf-dos.gpl DOS palette]. See the above link to the DevZone for more options.&lt;br /&gt;
&lt;br /&gt;
=== Import a palette file ===&lt;br /&gt;
Before you can use a palette in GIMP you must import it. You can import a palette form a file that has the correct palette applied or import a downloaded palette (*.gpl) file.&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file of which you know it has the correct palette in GIMP if you want to get the palette from that file (otherwise go to the next step). Decoded NewGRFs (using GRFCodec) surely will have the correct palette applied.&lt;br /&gt;
# Go to Windows &amp;gt; Dockable Dialogs &amp;gt; Palettes... The window from Fig. 3 with a list of builtin palettes will appear. &lt;br /&gt;
# Rightclick anywhere in the list with palettes and click Import Palette... from the context menu. The window from Fig 4. will appear. &lt;br /&gt;
# Now choose if you want to retrieve the palette from the opened image or if you want to import a palette from a palette file.&lt;br /&gt;
## Select Image below Select Source to get the palette from the current image file.&lt;br /&gt;
## Select Palette file below Select Source and browse to a *.gpl palette file to get the palette from that file.&lt;br /&gt;
# The palette will be shown. Give the palette a name and click Import. The TTD palette will now be added to the list of palettes.&lt;br /&gt;
&lt;br /&gt;
=== Applying a palette ===&lt;br /&gt;
Make sure the palette you want to use is imported in GIMP (see above).&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file in GIMP.&lt;br /&gt;
# Go to Image &amp;gt; Mode and check if RGB is selected. Select it if that is not the case, which will convert your graphics file to full-colour, maintaining the colours as they appear.&lt;br /&gt;
# Go to Image &amp;gt; Mode &amp;gt; Indexed... The window from Fig. 5 will appear. &lt;br /&gt;
# Select Use custom palette and then select the TTD palette from the palette list (click on the button showing a palette).&lt;br /&gt;
# Make sure to &#039;&#039;&#039;uncheck&#039;&#039;&#039; Remove unused colors from colormap.&lt;br /&gt;
# In the same window, you may select your choise of Dithering. The dither will convert all colours that are in the graphics file but not in the palette to the palette colours. Play around with the settings to find the best result. If the sprites in the image file were drawn properly (using only palette colours), you should see no difference.&lt;br /&gt;
# Click Convert to apply the palette (and dither) to this image file.&lt;br /&gt;
# Save the file as (preferrably) a PNG image.&lt;br /&gt;
&lt;br /&gt;
=== Saving a palette to file ===&lt;br /&gt;
If you want to share your imported palette, you must have a palette file.&lt;br /&gt;
&lt;br /&gt;
# Exit GIMP to automatically save your palette(s).&lt;br /&gt;
# Reopen GIMP (and the palette window via Windows &amp;gt; Dockable Dialogs &amp;gt; Palettes if this is closed).&lt;br /&gt;
# Rightclick your palette in the palette window and choose Copy Palette Location. This copies the path to the palette file to the clipboard&lt;br /&gt;
# With GIMP open, get the clipboard contents and browse to the specified folder (usualy ~/.gimp-2.6/palettes).&lt;br /&gt;
# Copy or upload the *.gpl file with the palette from there.&lt;br /&gt;
&lt;br /&gt;
Surely there must be an easier way to do this, but I haven&#039;t found that so far.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=Save_paletted_image_files&amp;diff=8279</id>
		<title>Save paletted image files</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=Save_paletted_image_files&amp;diff=8279"/>
		<updated>2012-04-16T18:14:28Z</updated>

		<summary type="html">&lt;p&gt;FooBar: Fix: there shouldn&amp;#039;t be a pipe in url links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This pagecovers how to apply a palette to a graphics file in several graphics editor. If your editor is not listed here and you know how to work with palettes using it, please add it here.&lt;br /&gt;
&lt;br /&gt;
You find a range of palettes with and without action colours (which might be useful for conversions) for various graphics programmes on the [http://dev.openttdcoop.org/documents/1| DevZone]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adobe Photoshop ==&lt;br /&gt;
[[Image:Photoshop palette window with windows ttd palette.png|thumb|50%|Fig. 1: Photoshop palette window showing in this case the Windows palette]]&lt;br /&gt;
[[Image:Photoshop indexed color window.png|thumb|50%|Fig. 2: Photoshop indexed color window]]&lt;br /&gt;
&lt;br /&gt;
In this subsection it is explained how to create a palette file and how to apply it using Adobe Photoshop (CS5 is used here, but identical or similar procedures apply in other versions of Photoshop). It is assumed that you have a clue about working with Photoshop.&lt;br /&gt;
&lt;br /&gt;
=== Retreiving a palette file ===&lt;br /&gt;
You can use an existing graphics file that has the correct palette applied to retrieve the palette and save it to a separate file. This palette can then be applied to graphics files that don&#039;t have a palette. You can skip this part if you have [http://dev.openttdcoop.org/attachments/1749/photoshop-ttd-dos.act downloaded a premade palette file].&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file of which you know it has the correct palette in Photoshop. Decoded NewGRFs (using GRFCodec) surely will have the correct palette applied.&lt;br /&gt;
# Go to Image &amp;gt; Mode &amp;gt; Color Table... The window from Fig. 1 will appear. &lt;br /&gt;
# Click Save... and store the palette file (*.act) somewhere on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Applying a palette from file ===&lt;br /&gt;
The Windows or DOS TTD palette must be applied to your graphics file for them to work in GRFCodec and NML. For the next steps we assume that you have a palette file (*.act) with the palette of your choice stored somewhere on your computer.&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file in Photoshop.&lt;br /&gt;
# Go to Image &amp;gt; Mode and check if RGB Color is checked. Select it if that is not the case, which will convert your graphics file to full-colour, maintaining the colours as they appear.&lt;br /&gt;
# Go to Image &amp;gt; Mode &amp;gt; Indexed Color... The window from Fig. 2 will appear. &lt;br /&gt;
# From the Palette drop-down, select Custom... The palette window (see Fig. 1) appears.&lt;br /&gt;
# Click Load... and browse the palette file. Click OK to close the palette window.&lt;br /&gt;
# In the indexed color window, you may select your choise of Dither. The dither will convert all colours that are in the graphics file but not in the palette to the palette colours. Either use the Diffusion dither (with preserving exact colors) or the Noise dither. Play around with the settings using the Preview to see the result and pick whatever looks best. If the sprites in the image file were drawn properly (using only palette colours), you should see no difference.&lt;br /&gt;
# Click OK to apply the palette file (and dither) to this image file. Note that this will flatten all layers (if any) in your graphics file.&lt;br /&gt;
# Save the file as (preferrably) a PNG image.&lt;br /&gt;
&lt;br /&gt;
=== Important note on PCX files in Photoshop ===&lt;br /&gt;
Photoshop has a quirk in which palettes from PCX files are read and written backwards. This is no problem is you stay with pcx, but it is if you convert from pcx to png (and the other way round). Any such conversion will have the palette stored backwards in the target file, making it unusable by GRFCodec or NML. Note:&lt;br /&gt;
* You cannot use the palette file saved from a PCX file for a PNG file;&lt;br /&gt;
* You cannot use the palette file saved from a PNG file for a PCX file;&lt;br /&gt;
* When converting PCX &amp;lt;-&amp;gt; PNG, you must convert to RGB Color first and then back to Indexed Color, applying the palette file of your target file format (e.g. when converting to PNG, apply the palette retrieved from a PNG file).&lt;br /&gt;
&lt;br /&gt;
== GIMP ==&lt;br /&gt;
[[Image:GIMP palette window.png|thumb|50%|Fig. 3: GIMP palette window]]&lt;br /&gt;
[[Image:GIMP import palette window.png|thumb|50%|Fig. 4: GIMP import pallete window showing the TTD Windows palette]]&lt;br /&gt;
[[Image:GIMP indexed color conversion window.png|thumb|50%|Fig. 5: GIMP indexed color conversion window]]&lt;br /&gt;
&lt;br /&gt;
In this subsection it is explained how to create a palette file and how to apply it using the GNU Image Manipulation Program (2.6 is used here, but identical or similar procedures should apply in other versions). It is assumed that you have a clue about working with GIMP.&lt;br /&gt;
&lt;br /&gt;
=== Download a palette file ===&lt;br /&gt;
In case of doubt you simply want to get the [http://dev.openttdcoop.org/attachments/1741/ttd-newgrf-dos.gpl DOS palette]. See the above link to the DevZone for more options.&lt;br /&gt;
&lt;br /&gt;
=== Import a palette file ===&lt;br /&gt;
Before you can use a palette in GIMP you must import it. You can import a palette form a file that has the correct palette applied or import a downloaded palette (*.gpl) file.&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file of which you know it has the correct palette in GIMP if you want to get the palette from that file (otherwise go to the next step). Decoded NewGRFs (using GRFCodec) surely will have the correct palette applied.&lt;br /&gt;
# Go to Windows &amp;gt; Dockable Dialogs &amp;gt; Palettes... The window from Fig. 3 with a list of builtin palettes will appear. &lt;br /&gt;
# Rightclick anywhere in the list with palettes and click Import Palette... from the context menu. The window from Fig 4. will appear. &lt;br /&gt;
# Now choose if you want to retrieve the palette from the opened image or if you want to import a palette from a palette file.&lt;br /&gt;
## Select Image below Select Source to get the palette from the current image file.&lt;br /&gt;
## Select Palette file below Select Source and browse to a *.gpl palette file to get the palette from that file.&lt;br /&gt;
# The palette will be shown. Give the palette a name and click Import. The TTD palette will now be added to the list of palettes.&lt;br /&gt;
&lt;br /&gt;
=== Applying a palette ===&lt;br /&gt;
Make sure the palette you want to use is imported in GIMP (see above).&lt;br /&gt;
&lt;br /&gt;
# Open a graphics file in GIMP.&lt;br /&gt;
# Go to Image &amp;gt; Mode and check if RGB is selected. Select it if that is not the case, which will convert your graphics file to full-colour, maintaining the colours as they appear.&lt;br /&gt;
# Go to Image &amp;gt; Mode &amp;gt; Indexed... The window from Fig. 5 will appear. &lt;br /&gt;
# Select Use custom palette and then select the TTD palette from the palette list (click on the button showing a palette).&lt;br /&gt;
# Make sure to &#039;&#039;&#039;uncheck&#039;&#039;&#039; Remove unused colors from colormap.&lt;br /&gt;
# In the same window, you may select your choise of Dithering. The dither will convert all colours that are in the graphics file but not in the palette to the palette colours. Play around with the settings to find the best result. If the sprites in the image file were drawn properly (using only palette colours), you should see no difference.&lt;br /&gt;
# Click Convert to apply the palette (and dither) to this image file.&lt;br /&gt;
# Save the file as (preferrably) a PNG image.&lt;br /&gt;
&lt;br /&gt;
=== Saving a palette to file ===&lt;br /&gt;
If you want to share your imported palette, you must have a palette file.&lt;br /&gt;
&lt;br /&gt;
# Exit GIMP to automatically save your palette(s).&lt;br /&gt;
# Reopen GIMP (and the palette window via Windows &amp;gt; Dockable Dialogs &amp;gt; Palettes if this is closed).&lt;br /&gt;
# Rightclick your palette in the palette window and choose Copy Palette Location. This copies the path to the palette file to the clipboard&lt;br /&gt;
# With GIMP open, get the clipboard contents and browse to the specified folder (usualy ~/.gimp-2.6/palettes).&lt;br /&gt;
# Copy or upload the *.gpl file with the palette from there.&lt;br /&gt;
&lt;br /&gt;
Surely there must be an easier way to do this, but I haven&#039;t found that so far.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>FooBar</name></author>
	</entry>
</feed>