From TTWiki

If you want to work with railtype labels, you need to teach NML about the labels you want to use. This is done by means of a railtypetable block. The railtypetable block can only be used in OpenTTD[1].

Railtypetable block

The railtypetable block contains a list of railtype labels, very similar to the cargotable block. Railtypetable blocks can do some more advanced things[2] than cargotable blocks, but that is outside the scope of this tutorial. There can be one railtypetable block in an NML file.

The railtypetable itself is no more than a list of railtype labels. The labels of the default railtypes are RAIL, ELRL, MONO and MGLV. Custom defined railtype labels used by several track sets can be looked up in the list of railtype labels. This is what the general syntax looks like (for the purpose of this tutorial):

railtypetable {
	<railtype_label1> [, <railtype_label2> [, <railtype_label3> ... ]]

You can add as many railtype labels to the railtypetable as you want/need. Railtype labels that start with a number (such as 3RDR) must be written as quoted string. If a railtype label doesn't start with a number, you may omit the quotes.

The railtypetable must exist before you use any of the labels in your NML code, so the best place for it is somewhere near the top of your NML file.


An example railtypetable block for the four railtypes available by default in OpenTTD:

railtypetable {

Example use when you use labels starting with a number:

railtypetable {
    RAIL, ELRL, "3RDR", "3RDC"

Referencing a railtype label

If you need to reference a railtype label from some other place in the code (e.g. from a property block), use the function railtype(<label>) substituting <label> for railtype labels that start with a number. Also use the quoted format inside the function. Railtype labels that don't start with an number can be referenced elsewhere also without the function in the unquoted format.

NML Tutorial: Railtypetable

  1. In theory you should be able to use railtypetable blocks in NewGRFs for TTDPatch if you limit the table to RAIL, MONO, MGLV (in that order) and guard it by an if (ttd_platform == PLATFORM_OPENTTD). This however has not been tested by the author of this tutorial. Without a railtypetable block you can still use the labels RAIL, MONO and MGLV.
  2. The advanced railtypetable is one that defines custom identifiers attached to a fallback label order. See the NML Documentation for details.