<?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=Hirogen2</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=Hirogen2"/>
	<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/wiki/Special:Contributions/Hirogen2"/>
	<updated>2026-05-02T02:22:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/NML_Syntax&amp;diff=8614</id>
		<title>NMLTutorial/NML Syntax</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/NML_Syntax&amp;diff=8614"/>
		<updated>2012-10-13T17:51:22Z</updated>

		<summary type="html">&lt;p&gt;Hirogen2: write style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
This page will be a theoretical introduction to the NML syntax. It is very well possible that you do not understand anything of what is written here. If that is the case, please read the page carefully &#039;&#039;once&#039;&#039; and then just continue with the next page which will take you on an example journey through the world of coding in NML.&lt;br /&gt;
&lt;br /&gt;
If you do understand this page completely, then it is very likely that you do not need the rest of this NML tutorial and just can look up what you need in the [http://newgrf-specs.tt-wiki.net/wiki/NML:Main NML Documentation]. At your option, you can browse through the tutorial quickly or just start making your NewGRF and figure things out as you go.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== NML is a programming language ==&lt;br /&gt;
NFO is not a programming language: it is hex editing. NML on the other hand is a human-readable programming language and contains things like if/else statements, operators such as &amp;lt;code&amp;gt;&amp;amp;&amp;amp;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;||&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;!=&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;amp;gt;=&amp;lt;/code&amp;gt; etc. and curly brackets to enclose groups of statements.&lt;br /&gt;
&lt;br /&gt;
If you already know a programming language such as C++ or PHP, it is probably very easy to understand and adapt to the NML syntax. If you are new to programming, you should understand a few concepts:&lt;br /&gt;
&lt;br /&gt;
=== If you are new to programming ===&lt;br /&gt;
; Name things the way you want&lt;br /&gt;
: If you define something, it is you who gives it a name. There is no set of rules how things should be called. If you want to name everything foo0001 through foo9999, that is up to you. That does not make it very easy to remember what is what, but it is not wrong per se. However, do not use any fancy symbols in names: you may use (capital) letters a through z, numbers 0 through 9 and an underscore (_). Numbers furthermore cannot be at the beginning of the name of an identifier.&lt;br /&gt;
&lt;br /&gt;
; When referencing something, it needs to exist&lt;br /&gt;
: If you want to use a string, the string needs to exists. That probably makes as much sense to you as that a circle is round, right? But it goes further than that: if you define a vehicle and want it to use this and that graphics, the graphics need to be defined &#039;&#039;before&#039;&#039; you define the vehicle that uses it. This applies to everything; if your reference something somewhere, that something needs to exists and essentially needs to be before the reference.&lt;br /&gt;
&lt;br /&gt;
; Compilers do not understand typos&lt;br /&gt;
: If you make a typo, the compiler (in this case nmlc) will not understand what you mean. This especially applies to the names of things we discussed earlier. If you name your vehicle definition KirbyPaulTank, then you must use the exact capitalization everywhere. For a compiler, Kirbypaultank, kirbypaultank, kirbypaulTank etc. are all completely different things. You need to pay special attention to this if you come from Windows. In Windows, there is no difference if you give a file or directory a name with or without captials; in a programming language, with or without capitals is a completely different thing and essentially a typo when not used consistently.&lt;br /&gt;
&lt;br /&gt;
; Add more comments than you think is necessary&lt;br /&gt;
: When working on a piece of code, you easily remember what does what and why you made it the way you did. However, if you do not, look at a piece of code for a couple of months, chances are you have no clue what it does if you have not commented it. Using decent names for definitions helps a great deal towards reducing the amount of comments, but ideally every code block should have a line stating what it is for and more complicated things also get comments as you go. If you do certain things differently for a reason, state &#039;&#039;why&#039;&#039; you did that. If you work with more people on one project, comments are vital in helping fellow developers understand why you did what.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== NML structure: blocks ==&lt;br /&gt;
NML files are mainly composed from blocks. A block starts with the type of the block, optional arguments and then the contents enclosed by curly braces. Some blocks are supplied with an identifier (&#039;&#039;a name&#039;&#039;) as argument, some with even more arguments and some are only referenced by their type. The basic block syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
type {&lt;br /&gt;
    &amp;lt;block_contents&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
type &amp;lt;identifier&amp;gt; {&lt;br /&gt;
    &amp;lt;block_contents&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
type (&amp;lt;identifier&amp;gt;, &amp;lt;argument1&amp;gt;, [&amp;lt;argument2&amp;gt; [,...]] {&lt;br /&gt;
    &amp;lt;block_contents&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;Note: the identifier is not necessarily the first argument of a block in case of multiple arguments.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When a block syntax is explained in the tutorial, some arguments may be optional. These are written between [ straight/square brackets ]. These brackets indicate that something is optional; the brackets are not part of the actual NML code. &amp;lt;code&amp;gt;[,...]&amp;lt;/code&amp;gt; means that you can have any number of arguments of the same type as the previous argument. Things between &amp;lt; pointy/angular brackets &amp;gt; must be replaced with actual content. What this content must be is explained directly after the introduction of the block&#039;s syntax. Also, pointy brackets are not part of actual NML code. Round and curly brackets are part of the NML code and must be written as indicated. Words or text not between pointy brackets is also part of the NML code and must appear as indicated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Currently, the following block types exist:&lt;br /&gt;
&amp;lt;div style=&amp;quot;float:left&amp;quot;&amp;gt;&lt;br /&gt;
* grf&lt;br /&gt;
* item&lt;br /&gt;
* recolour_sprite&lt;br /&gt;
* template&lt;br /&gt;
* spriteset&lt;br /&gt;
* spritegroup&lt;br /&gt;
* spritelayout&lt;br /&gt;
* tilelayout&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;float:left&amp;quot;&amp;gt;&lt;br /&gt;
* switch&lt;br /&gt;
* produce&lt;br /&gt;
* random_switch&lt;br /&gt;
* cargotable&lt;br /&gt;
* railtypetable&lt;br /&gt;
* error&lt;br /&gt;
* disable_item&lt;br /&gt;
* deactivate&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;float:left&amp;quot;&amp;gt;&lt;br /&gt;
* engine_override&lt;br /&gt;
* replace&lt;br /&gt;
* replacenew&lt;br /&gt;
* font_glpyh&lt;br /&gt;
* alt_sprites&lt;br /&gt;
* town_names&lt;br /&gt;
* snowline&lt;br /&gt;
* basecost&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;clear:left&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some special &amp;quot;blocks&amp;quot;, which are not really blocks, but language constructs, exist as well:&lt;br /&gt;
* if&lt;br /&gt;
* else&lt;br /&gt;
&lt;br /&gt;
Furthermore, there are too many [http://newgrf-specs.tt-wiki.net/wiki/NML:Builtin_functions functions] to list here. For now, you can forget these if you want, but it is good to have seen their names.&lt;br /&gt;
&lt;br /&gt;
The blocks define things that can be referenced or make new things available in the game. Some blocks can contain sub-blocks. The &amp;lt;code&amp;gt;grf&amp;lt;/code&amp;gt; block can contain a &amp;lt;code&amp;gt;param&amp;lt;/code&amp;gt; subblock to add parameter settings. The &amp;lt;code&amp;gt;item&amp;lt;/code&amp;gt; block can contain &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;graphics&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;livery_override&amp;lt;/code&amp;gt; subblocks. &lt;br /&gt;
&lt;br /&gt;
If you need to do some calculations, you do those outside the blocks, or in some special cases, in a block&#039;s &#039;&#039;expression&#039;&#039; argument, but never inside a block. &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;s and &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt;s also have no place inside blocks and can only be used outside them.&lt;br /&gt;
&lt;br /&gt;
=== Identifiers ===&lt;br /&gt;
As you have read earlier, some blocks need to have an &#039;&#039;identifier&#039;&#039;. You can see this identifier as a name for the block and you choose this identifier yourself.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;All identifiers need to be unique throughout you NML file!&#039;&#039;&#039; This even applies for identifiers of totally different blocks. An easy method to avoid duplicate identifiers is to precede the identifier name with the name of the block type. While this is not foolproof, it simply reduces the chances for duplicates. It is also a good idea to add the name of the item (vehicle, object, etc.) an identifier belongs to to the name of the identifier.&lt;br /&gt;
&lt;br /&gt;
With both the block name and item name in the identifier, you can also see quickly from the identifier what this is for, without having to write that down somewhere seperately.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
Some blocks can do multiple things. For example, the &amp;lt;code&amp;gt;item&amp;lt;/code&amp;gt; can define a train, but also a road vehicle, ship, or aircraft. In case of such a block, you need to set which &#039;&#039;feature&#039;&#039; the block is for and supply this to the block as an argument. Below is a table of available features:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;t&amp;quot;&lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_TRAINS&lt;br /&gt;
| Trains&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_ROADVEHS&lt;br /&gt;
| Road vehicles&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_SHIPS&lt;br /&gt;
| Ships&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_AIRCRAFT&lt;br /&gt;
| Aircraft&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_STATIONS&lt;br /&gt;
| Train stations&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_CANALS&lt;br /&gt;
| Canals&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_BRIDGES&lt;br /&gt;
| Bridges&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_HOUSES&lt;br /&gt;
| Town houses&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_GLOBALVARS&lt;br /&gt;
| Various global variables&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_INDUSTRYTILES&lt;br /&gt;
| Industry tiles (visible part of industries)&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_INDUSTRIES&lt;br /&gt;
| Industries&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_CARGOS&lt;br /&gt;
| Cargo types&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_SOUNDEFFECTS&lt;br /&gt;
| Sound effects&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_AIRPORTS&lt;br /&gt;
| Airports&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_SIGNALS&lt;br /&gt;
| Train signals&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_OBJECTS&lt;br /&gt;
| Non-interactive objects (example: lighthouse)&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_RAILTYPES&lt;br /&gt;
| Rail types&lt;br /&gt;
|-&lt;br /&gt;
| FEAT_AIRPORTTILES&lt;br /&gt;
| Airport tiles (visible part of airports)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
As said before, it is useful to add comments to your NML code to indicate what things are for.&lt;br /&gt;
&lt;br /&gt;
Comments can be written as comment block or as inline comment. Comment blocks go between different lines of NML code, while inline comments can also go there as well as at the end of each line.&lt;br /&gt;
&lt;br /&gt;
Comment block example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
This is a comment block, it starts with a slash and an asterisk.&lt;br /&gt;
It can span multiple lines&lt;br /&gt;
Before it ends with an asterisk and a slash&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Inline comment example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue&amp;quot;&amp;gt;&lt;br /&gt;
// An inline comment is preceded by two slashes&lt;br /&gt;
// If you need multiple lines, each line gets two slashes in front&lt;br /&gt;
&lt;br /&gt;
grf {&lt;br /&gt;
    name: string(STR_GRF_NAME); // it can also go at the end of a line&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Yes, that is a bunch of stuff with little hands-on examples, but I warned you about that. You will find (most of) these different blocks explained in the remainder of this tutorial. And, of course, how every block should be written is clearly documented in the [http://newgrf-specs.tt-wiki.net/wiki/NML:Block_syntax block syntax] chapter of the NML Documentation.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Language files|Starting an NML file}}&lt;/div&gt;</summary>
		<author><name>Hirogen2</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Language_files&amp;diff=8613</id>
		<title>NMLTutorial/Language files</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Language_files&amp;diff=8613"/>
		<updated>2012-10-13T17:41:21Z</updated>

		<summary type="html">&lt;p&gt;Hirogen2: write style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
All texts (or &#039;&#039;strings&#039;&#039;) you want or need to use in a NewGRF go into a language file. Each language has its own language file, which makes translations in NML very easy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Language folder structure ==&lt;br /&gt;
Of course you want to keep all the source files for one NewGRF together in one directory, right? In this directory, create a subdirectory with the name &amp;lt;code&amp;gt;lang&amp;lt;/code&amp;gt;. This is the default directory name NML looks in for language files. You can use a different name if you want to, but then you need to teach NML this name.&lt;br /&gt;
&lt;br /&gt;
=== File extensions ===&lt;br /&gt;
Every language file needs to have the &amp;lt;code&amp;gt;.lng&amp;lt;/code&amp;gt; file extension, otherwise NML will not recognise them.&lt;br /&gt;
&lt;br /&gt;
=== Default language ===&lt;br /&gt;
You need to have exactly one default language for your NewGRF project. This language will be used if the user selects a language not available in the NewGRF, or if some translation is not complete. The default default language is &#039;&#039;english.lng&#039;&#039;. If that is fine with you, you do not have to make any other settings. If you want a different default language, you need to tell NML which one this is; see the [[NMLTutorial/Installation#NML_Commandline_Options|installation page]] on which commandline option to supply to do this.&lt;br /&gt;
&lt;br /&gt;
=== Example directory structure ===&lt;br /&gt;
As a result, your directory structure should look something like the following:&lt;br /&gt;
&lt;br /&gt;
 mygrf&lt;br /&gt;
  \_ lang&lt;br /&gt;
  |   \_ english.lng&lt;br /&gt;
  |   \_ other_language.lng&lt;br /&gt;
  \_ mygrf.nml (which we will create later)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Language file structure ==&lt;br /&gt;
The contents of each language file itself has the following structure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;pseudo&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid &amp;lt;number&amp;gt;&lt;br /&gt;
&amp;lt;string-name&amp;gt;                                                   :&amp;lt;text&amp;gt;&lt;br /&gt;
&amp;lt;string-name&amp;gt;                                                   :&amp;lt;text&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;number&amp;gt;&amp;lt;/code&amp;gt; is the number of the language in this file. You can look these numbers up [http://newgrf-specs.tt-wiki.net/wiki/NML:Language_files here]. This number needs to be written with the hexadecimal prefix &amp;lt;code&amp;gt;0x&amp;lt;/code&amp;gt;. For example, the language number for British English is 01, so as &amp;lt;code&amp;gt;&amp;lt;number&amp;gt;&amp;lt;/code&amp;gt; you need to put &amp;lt;code&amp;gt;0x01&amp;lt;/code&amp;gt;. Dutch has 1F as language number, so in case of &amp;lt;code&amp;gt;dutch.lng&amp;lt;/code&amp;gt;, you put &amp;lt;code&amp;gt;0x1F&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== String names ===&lt;br /&gt;
Each piece of text, a string, needs to have a unique &amp;lt;code&amp;gt;&amp;lt;string-name&amp;gt;&amp;lt;/code&amp;gt;. For this, you can choose whatever you want, but it is common practice to start each string name with STR_ and write it completely in capitals. That way, you do not get duplicates with other names you will be using in your NML file, and the captitals make the code a little bit easier to read.&lt;br /&gt;
&lt;br /&gt;
Every new string name will start on a new line in the language file.&lt;br /&gt;
&lt;br /&gt;
=== Texts ===&lt;br /&gt;
The text, or strings, themselves are written directly behind the string name, both completely on a single line. The string name and the string are separated by a colon. If you want to align the strings, you can do that by adding spaces of tabs &#039;&#039;in front of&#039;&#039; the colon. If you add them behind the colon, this whitespace will be part of the string!&lt;br /&gt;
&lt;br /&gt;
=== String codes ===&lt;br /&gt;
You can use some special string codes inside strings, for instance, to instruct the game to continue the string on a new line, to use colours in your string, or to do some special things with strings. The formatting for these string codes is the same as [http://wiki.openttd.org/Strings used by OpenTTD]. However, not all string codes are available in all locations where strings are displayed. Colours and special characters are generally available anywhere; other things you will just have to try and see.&lt;br /&gt;
&lt;br /&gt;
=== ASCII or Unicode ===&lt;br /&gt;
When saving the language file, you should pay a little attention to the character encoding you use. If you only use ISO8859-1 or -15 (Latin-1/-15) characters in your language file, you can save as both ASCII and UTF-8 (one of many Unicode encodings). If you use non-Latin characters, such as for Cyrillic, Arabic or Asian languages, you must save as UTF-8.&lt;br /&gt;
&lt;br /&gt;
=== Comments in language files ===&lt;br /&gt;
If you want to add comments in language files to make some notes in it that are not string definitions, start the line with the comment with a hash tag (#). Then you can write anything you want on that line and it will not be interpreted by NML.&lt;br /&gt;
&lt;br /&gt;
=== Example language file ===&lt;br /&gt;
An example english.lng could contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
# This is the English language file&lt;br /&gt;
&lt;br /&gt;
# GRF name and description definitions&lt;br /&gt;
STR_GRF_NAME        :My GRF 0.1.0&lt;br /&gt;
STR_GRF_DESCRIPTION :My GRF is the best there is and makes all other grfs obsolete!{}{COPYRIGHT}2011 Derp{}License: GPL v2&lt;br /&gt;
&lt;br /&gt;
# vehicle names&lt;br /&gt;
STR_NAME_MYVEHICLE  :General Robotics Anti-Grav UFO Mark X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the string codes for a new line {} and the copyright symbol in the GRF description.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Custom string codes ==&lt;br /&gt;
For things such as a version number, it is useful to define a custom string code. That way, you do not have to go and update the version number in every language file whenever you make a new release. You can also use it for the GRF title and basically anything you want, but these are the most useful applications.&lt;br /&gt;
&lt;br /&gt;
Custom string codes go in a file called &amp;lt;code&amp;gt;custom_tags.txt&amp;lt;/code&amp;gt; which resides outside the &#039;&#039;lang&#039;&#039; directory, next to your nml file:&lt;br /&gt;
&lt;br /&gt;
 mygrf&lt;br /&gt;
  \_ lang&lt;br /&gt;
  |   \_ english.lng&lt;br /&gt;
  |   \_ other_language.lng&lt;br /&gt;
  \_ custom_tags.txt&lt;br /&gt;
  \_ mygrf.nml&lt;br /&gt;
&lt;br /&gt;
The format of &amp;lt;code&amp;gt;custom_tags.txt&amp;lt;/code&amp;gt; is similar to a language file, but does not have the &amp;lt;code&amp;gt;##grflangid&amp;lt;/code&amp;gt; definition, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue&amp;quot;&amp;gt;&lt;br /&gt;
VERSION  :0.1.0&lt;br /&gt;
TITLE    :My GRF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The same rules for character encoding apply, and once you have this, you can change your language file into something like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x01&lt;br /&gt;
# This is the English language file&lt;br /&gt;
&lt;br /&gt;
# GRF name and description definitions&lt;br /&gt;
STR_GRF_NAME        :{TITLE} {VERSION}&lt;br /&gt;
STR_GRF_DESCRIPTION :{TITLE} is the best there is and makes all other grfs obsolete!{}{COPYRIGHT}2011 Derp{}License: GPL v2&lt;br /&gt;
&lt;br /&gt;
# vehicle names&lt;br /&gt;
STR_NAME_MYVEHICLE  :General Robotics Anti-Grav UFO Mark X&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dutch language file for example then can use these same custom sting codes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:darkblue&amp;quot;&amp;gt;&lt;br /&gt;
##grflangid 0x1F&lt;br /&gt;
# This is the Dutch language file&lt;br /&gt;
&lt;br /&gt;
# GRF name and description definitions&lt;br /&gt;
STR_GRF_NAME        :{TITLE} {VERSION} - Mijn GRF&lt;br /&gt;
STR_GRF_DESCRIPTION :Mijn GRF is de beste die er is en maakt alle andere grfs overbodig!{}{COPYRIGHT}2011 Derp{}Licentie: GPL v2&lt;br /&gt;
&lt;br /&gt;
# we will use the English vehicle name as well for Dutch, and don&#039;t re-define it here.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you know how to create language files, where they need to go and what you should put into them. Go ahead and create the default (English) language file and a language file for your own language (if English is your own language, then stick with the one default file). Add a name and description for the NewGRF you want to make and use &amp;lt;code&amp;gt;custom_tags.txt&amp;lt;/code&amp;gt; where it is useful.&lt;br /&gt;
&lt;br /&gt;
Got that? Great! Now there is only one step left before you are going to create your actual NML file!&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Graphic files|NML Syntax}}&lt;/div&gt;</summary>
		<author><name>Hirogen2</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Graphic_files&amp;diff=8612</id>
		<title>NMLTutorial/Graphic files</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Graphic_files&amp;diff=8612"/>
		<updated>2012-10-13T17:34:10Z</updated>

		<summary type="html">&lt;p&gt;Hirogen2: wr style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
You can use any graphics file format as long as it is supported by the [http://www.pythonware.com/products/pil/ Python Image Library] and as long the graphics file has one of the TTD palettes applied.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What image files should I use? ==&lt;br /&gt;
If you are unsure about what file format to use, take PNG as a safe bet. It can work with palettes and has the added advantage that it can be viewed by browsers and as such, you can just upload your sprite files to the forums if you want to show them. PNG files are also widely supported by graphics editors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is this palette business? ==&lt;br /&gt;
Graphics for TTD can only use a limited set of colours (OpenTTD 32bpp graphics are an exception to this; while NML can handle these for you, it is not covered in this tutorial). Check the NewGRF Specs for [http://newgrf-specs.tt-wiki.net/wiki/PalettesAndCoordinates#Palettes what these palettes are] and which colours are available to use. The DOS palette has a few more colours, so if you are still in the position to choose, go for that.&lt;br /&gt;
&lt;br /&gt;
In theory, you can draw in true colour (24 or 32 bpp) and then convert your result to the TTD palette, but that usually does not work out too well. It is best to only use the colours from the palette in the first place. Each sprite should get a blue background, for which you use the blue from index 0 (indicated as &amp;quot;Transparent&amp;quot; on the page of the link above, or hex colour #0000FF).&lt;br /&gt;
&lt;br /&gt;
Make sure to actually save the graphics files with a palette applied, or NML will complain that you do not have one. If you do not have this palette, you can extract it from any decoded GRF file or [http://newgrf-specs.tt-wiki.net/wiki/NML:Graphic_files download] a premade palette file.&lt;br /&gt;
&lt;br /&gt;
See [[Save paletted image files]] for how to create image files with the correct pallete applied.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How do I draw sprites? ==&lt;br /&gt;
This tutorial is not about drawing, but about coding once you have drawn. If you want to learn how to draw sprites, check the [[GraphicsTutorial]].&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar|Installation|Language files}}&lt;/div&gt;</summary>
		<author><name>Hirogen2</name></author>
	</entry>
	<entry>
		<id>https://www.tt-wiki.net/index.php?title=NMLTutorial/Installation&amp;diff=8611</id>
		<title>NMLTutorial/Installation</title>
		<link rel="alternate" type="text/html" href="https://www.tt-wiki.net/index.php?title=NMLTutorial/Installation&amp;diff=8611"/>
		<updated>2012-10-13T17:32:32Z</updated>

		<summary type="html">&lt;p&gt;Hirogen2: write style&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLTutorial}}&lt;br /&gt;
&lt;br /&gt;
NML is written in Python and therefore can be made to run on every operating system that can run Python. This includes the popular operating sytems Linux, Mac OS X and Windows. Below you will find a description on how to install NML and how to use the command-line NML program on your operating system.&lt;br /&gt;
&lt;br /&gt;
{{Note|The NML Documentation reflects the latest state of the NML program. Make sure to update your NML regularly, especially if you find something not working that should work according to the documentation.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Linux ==&lt;br /&gt;
NML requires Python, the Python Image Library and PLY (Python Lex-Yacc). These three things are best installed from your package manager. If you are looking to compiling NML yourself, you also need the Python Setuptools. Note that NML currently only runs on Python 2.5 through 2.7, but not 3.x. Look for the following in your package manager:&lt;br /&gt;
* python (you might already have this)&lt;br /&gt;
* python-imaging (pil)&lt;br /&gt;
* python-ply&lt;br /&gt;
* python-setuptools&lt;br /&gt;
&lt;br /&gt;
=== Installing NML ===&lt;br /&gt;
For Linux users, there are several ways to get NML. If you have Python 2.7, you can get it as precompiled binary. Otherwise you should be able to compile NML without too much effort. Pick the method of your choice below.&lt;br /&gt;
&lt;br /&gt;
==== Installing NML as precompiled binary (recommended) ====&lt;br /&gt;
The latest version of NML is available as RPM package from the #openttdcoop DevZone. You can find it here: http://bundles.openttdcoop.org/nml/nightlies/LATEST/rpms/. This package is known to work on openSUSE and Red Hat (including Fedora and CentOS) distributions.&lt;br /&gt;
&lt;br /&gt;
You can use the terminal to install this package through your package manager (make sure to run it as superuser). For example on Fedora:&lt;br /&gt;
&lt;br /&gt;
 sudo bash&lt;br /&gt;
 yum install &amp;lt;nowiki&amp;gt;http://bundles.openttdcoop.org/nml/nightlies/LATEST/rpms/nml-rXXXX-suseYYYY.noarch.rpm&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure to replace XXXX and YYYY in the url with the actual version numbers you found via the link above. Enter &amp;quot;y&amp;quot; when asked, and when done, do not forget to &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; the root shell again, preventing yourself from doing stupid things from this point on.&lt;br /&gt;
&lt;br /&gt;
==== Compiling NML yourself ====&lt;br /&gt;
The other option to get NML is to compile it yourself. First, you need to get the source from http://bundles.openttdcoop.org/nml/nightlies/LATEST/ or via Mercurial checkout from http://hg.openttdcoop.org/nml (&amp;lt;code&amp;gt;hg clone &amp;lt;nowiki&amp;gt;http://hg.openttdcoop.org/nml&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Also, this time, you need the terminal as superuser. Then change directory to the (extracted) NML source and run &amp;lt;code&amp;gt;python setup.py install&amp;lt;/code&amp;gt;. For example:&lt;br /&gt;
&lt;br /&gt;
 sudo bash&lt;br /&gt;
 cd ~/Downloads/nml-rXXXX&lt;br /&gt;
 python setup.py install&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
=== Using NML ===&lt;br /&gt;
As said before, NML is a command-line program and therefore does not have a GUI; much like GRFCodec, in fact. That means you need to run it from a terminal window. The NML program itself is called &amp;lt;code&amp;gt;nmlc&amp;lt;/code&amp;gt; and the general usage is &amp;lt;code&amp;gt;nmlc [options] &amp;lt;filename&amp;gt;&amp;lt;/code&amp;gt;. First, change directory to the directory which has your nml file. Then run the nmlc program to compile your GRF. For example:&lt;br /&gt;
&lt;br /&gt;
 cd ~/grfs/mygrf&lt;br /&gt;
 nmlc -c --grf mygrf.grf mygrf.nml&lt;br /&gt;
&lt;br /&gt;
This will encode the nml file ~/grfs/mygrf/mygrf.nml into the GRF file ~/grfs/mygrf/mygrf.grf. The &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt; option is not mandatory, but crops extraneous blue from sprites, reducing the filesize of the GRF file.&lt;br /&gt;
&lt;br /&gt;
All command-line options available to NML are available via the &amp;lt;code&amp;gt;nmlc -h&amp;lt;/code&amp;gt; command and are also [[#NML Command-line Options|listed]] on this page. Now that you have NML and know how to use it, you can continue this tutorial to learn how to create an actual grf file using NML.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mac OS X ==&lt;br /&gt;
For Mac OS X, you are currently required to compile NML yourself, as there are no precompiled binaries available.&lt;br /&gt;
&lt;br /&gt;
=== Installing NML ===&lt;br /&gt;
Please add a detailed explanation if you know how to do this.&lt;br /&gt;
&lt;br /&gt;
=== Using NML ===&lt;br /&gt;
Please add a detailed explanation if you know how to do this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Windows ==&lt;br /&gt;
NML is available as pre-built (32-bit) Windows executable from the #openttdcoop DevZone, so there is no need to compile it yourself.&lt;br /&gt;
&lt;br /&gt;
=== Installing NML ===&lt;br /&gt;
Go to http://bundles.openttdcoop.org/nml/nightlies/LATEST/ and download nml-rXXXX-windows-win32.zip, replacing XXXX with the actual version number of the package. The ZIP file contains a number of files that all need to stay together. Where these files go depends on whether you want to take the easy route or do it properly.&lt;br /&gt;
&lt;br /&gt;
==== Easy route ====&lt;br /&gt;
The easy route is to extract all the NML program files in the same directory as your NML project (where your file with the NML code and the directories with language and graphics files will go later). With this, you can use the NML program for this project alone. If you want to work on multiple NewGRF projects coded in NML, you need to copy the NML program files to each of these project directories.&lt;br /&gt;
&lt;br /&gt;
==== Proper route ====&lt;br /&gt;
If you want to run NML from any directory, you need to add the directory containing the nmlc.exe executable (and related files) to your PATH environment variable. This can break Windows if you do not do it correctly, so follow the instructions carefully. The instructions have been written for Windows 7 and may differ slightly on other Windows versions.&lt;br /&gt;
&lt;br /&gt;
First, extract the NML program files to a directory of your choice, e.g. C:\tools\NML. It is preferred that you do not have spaces in the directory path, so avoid the &amp;quot;Program Files&amp;quot; directory. Once you have that, remember the directory path and follow these steps carefully:&lt;br /&gt;
# Rightclick &amp;quot;Computer&amp;quot; on the desktop or in the Start menu and select &#039;&#039;Properties&#039;&#039;. This will open the System window from the Configuration Panel.&lt;br /&gt;
# Click &#039;&#039;Advanced system settings&#039;&#039; in the left pane. This will open the System Properties window.&lt;br /&gt;
# Click the &#039;&#039;Advanced&#039;&#039; tab.&lt;br /&gt;
# On the Advanced tab, click the &#039;&#039;Environment Variables...&#039;&#039; button. This will open the Environment Variables window.&lt;br /&gt;
# In the bottom half of the window below System variables, find the &#039;&#039;Path&#039;&#039; entry and select it.&lt;br /&gt;
# With the Path entry selected, click the &#039;&#039;Edit...&#039;&#039; button. An edit box will appear.&lt;br /&gt;
# &#039;&#039;&#039;Do not touch the Variable name and do not remove anything from the Variable value!&#039;&#039;&#039; (This is where you can break your computer.)&lt;br /&gt;
# Put your cursor at the end of the &#039;&#039;Variable name&#039;&#039; box and type a semicolon followed by the directory path to the NML program, in this case &amp;lt;code&amp;gt;;C:\tools\NML&amp;lt;/code&amp;gt;&lt;br /&gt;
# Confirm your changes by clicking the &#039;&#039;OK&#039;&#039; button in each of the three windows.&lt;br /&gt;
&lt;br /&gt;
Now you can use the NML program from any directory on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Using NML ===&lt;br /&gt;
As said before, NML is a command-line program and therefore does not have a GUI; much like GRFCodec, in fact. That means you need to run it from a command prompt window. You can start the command prompt from Start &amp;gt; Programs &amp;gt; Accessories &amp;gt; Command Prompt, or by entering &amp;lt;code&amp;gt;cmd&amp;lt;/code&amp;gt; into the Run dialog or the Start menu search bar.&lt;br /&gt;
&lt;br /&gt;
Next, you need to change directory to the project folder which has your NML (code) file in it. Then run the nmlc program to compile your GRF. For example:&lt;br /&gt;
&lt;br /&gt;
 D:&lt;br /&gt;
 cd D:\grfs\mygrf&lt;br /&gt;
 nmlc -c --grf mygrf.grf mygrf.nml&lt;br /&gt;
&lt;br /&gt;
This will encode the nml file &amp;lt;code&amp;gt;D:\grfs\mygrf\mygrf.nml&amp;lt;/code&amp;gt; into the GRF file &amp;lt;code&amp;gt;D:\grfs\mygrf\mygrf.grf&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt; option is not mandatory, but crops extraneous blue from sprites, reducing the filesize of the grf file. Note that if you have any spaces in a directory or file name, you need to enclose that complete path or filename in double quotes, e.g.: &amp;lt;code&amp;gt;cd &amp;quot;D:\Users\Username\My Documents\mygrf&amp;quot;&amp;lt;/code&amp;gt;. It is therefore recommended not to have any spaces.&lt;br /&gt;
&lt;br /&gt;
All command-line options available to NML are available via the &amp;lt;code&amp;gt;nmlc -h&amp;lt;/code&amp;gt; command and are also [[#NML Command-line Options|listed]] on this page. Now that you have NML and know how to use it, you can continue this tutorial to learn how to create an actual grf file using NML.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== NML Command-line Options ==&lt;br /&gt;
&#039;&#039;From the NML readme&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 Usage: nmlc [options] &amp;lt;filename&amp;gt;&lt;br /&gt;
 Where &amp;lt;filename&amp;gt; is the nml file to parse&lt;br /&gt;
 &lt;br /&gt;
 Options:&lt;br /&gt;
  --version             show program&#039;s version number and exit&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  -d, --debug           write the AST to stdout&lt;br /&gt;
  -s, --stack           Dump stack when an error occurs&lt;br /&gt;
  --grf=&amp;lt;file&amp;gt;          write the resulting grf to &amp;lt;file&amp;gt;&lt;br /&gt;
  --nfo=&amp;lt;file&amp;gt;          write nfo output to &amp;lt;file&amp;gt;&lt;br /&gt;
  -c                    crop extraneous transparent blue from real sprites&lt;br /&gt;
  -u                    save uncompressed data in the grf file&lt;br /&gt;
  --nml=&amp;lt;file&amp;gt;          write optimized nml to &amp;lt;file&amp;gt;&lt;br /&gt;
  -o &amp;lt;file&amp;gt;, --output=&amp;lt;file&amp;gt;&lt;br /&gt;
                        write output(nfo/grf) to &amp;lt;file&amp;gt;&lt;br /&gt;
  -t &amp;lt;file&amp;gt;, --custom-tags=&amp;lt;file&amp;gt;&lt;br /&gt;
                        Load custom tags from &amp;lt;file&amp;gt; [default:&lt;br /&gt;
                        custom_tags.txt]&lt;br /&gt;
  -l &amp;lt;dir&amp;gt;, --lang-dir=&amp;lt;dir&amp;gt;&lt;br /&gt;
                        Load language files from directory &amp;lt;dir&amp;gt; [default:&lt;br /&gt;
                        lang]&lt;br /&gt;
  -a &amp;lt;dir&amp;gt;, --sprites-dir=&amp;lt;dir&amp;gt;&lt;br /&gt;
                        Store 32bpp sprites in directory &amp;lt;dir&amp;gt; [default:&lt;br /&gt;
                        sprites]&lt;br /&gt;
  --default-lang=&amp;lt;file&amp;gt;&lt;br /&gt;
                        The default language is stored in &amp;lt;file&amp;gt; [default:&lt;br /&gt;
                        english.lng]&lt;br /&gt;
  --start-sprite=&amp;lt;num&amp;gt;  Set the first sprite number to write (do not use&lt;br /&gt;
                        except when you output nfo that you want to include in&lt;br /&gt;
                        other files)&lt;br /&gt;
  -p &amp;lt;palette&amp;gt;, --palette=&amp;lt;palette&amp;gt;&lt;br /&gt;
                        Force nml to use the palette &amp;lt;pal&amp;gt; [default: ANY].&lt;br /&gt;
                        Valid values are &#039;DOS&#039;, &#039;WIN&#039;, &#039;ANY&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Text editor ==&lt;br /&gt;
NML files and its language files are plain text files and should be edited in a plain text editor. Your operating system most likely comes with a text editor with limited functionality. As such it is recommended to choose an editor with more functionality:&lt;br /&gt;
; Cross-platform&lt;br /&gt;
* [http://www.geany.org/ Geany]&lt;br /&gt;
; Linux&lt;br /&gt;
* [http://kate-editor.org/get-it/ Kate], vim&lt;br /&gt;
; MacOS&lt;br /&gt;
* XCode&lt;br /&gt;
; Windows&lt;br /&gt;
* [http://notepad-plus-plus.org/ Notepad++]&lt;br /&gt;
&lt;br /&gt;
If you use an editor which you think is quite good and not listed here, you are welcome to add it.&lt;br /&gt;
&lt;br /&gt;
=== Syntax highlighting ===&lt;br /&gt;
Syntax highlighting adds some colour to NML code, which makes it easier to read.&lt;br /&gt;
&lt;br /&gt;
At the #openttdcoop DevZone there are syntax highlighter extensions available for [http://dev.openttdcoop.org/documents/24 Notepad++] and [http://dev.openttdcoop.org/documents/26 Geany]. If you want to create your own syntax highlighter, there is a [http://dev.openttdcoop.org/documents/25 script] available as well that will help you create the keyword lists.&lt;br /&gt;
&lt;br /&gt;
{{NMLTutorialNavbar||Graphic files}}&lt;/div&gt;</summary>
		<author><name>Hirogen2</name></author>
	</entry>
</feed>