Rail types

Railtype variables

namevalue rangecomment
terrain_typeTILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
enhanced_tunnels0should custom tunnel entrances be modified other values than 0 might be returned
level_crossing_statusLEVEL_CROSSING_CLOSED, LEVEL_CROSSING_OPEN
build_date 0 .. 5000000 for depots only: build date of the depot in days since 0

Railtype properties

propertyvalue rangecomment
label 4-byte stringnames of default rail types: "RAIL", "ELRL", "MONO", "MLEV", "3RDR"
introduction_date date(yyyy,mm,dd)Valid range for yyyy is 0 ... 5000000. Since OpenTTD r21842
name string
menu_text string
build_window_caption string
autoreplace_text string
new_engine_text string
compatible_railtype_listlist of railtype labelse.g. ["RAIL", "ELRL", "MONO"]
powered_railtype_list list of railtype labels
railtype_flags bitmask(RAILTYPE_FLAG_CATANERY, RAILTYPE_FLAG_NO_LEVEL_CROSSING (OpenTTD r20049))
curve_speed_multiplier 0...65525max curve speed is defined as multiple of the base curve speed (see below)
station graphics RAILTYPE_STATION_NORMAL, RAILTYPE_STATION_MONORAIL, RAILTYPE_STATION_MAGLEV
construction_cost 0 ... 65525per piece of track as multiplier to PR_BUILD_RAIL base cost. Since OpenTTD r19307
speed_limit 0 ... 65525 km/h (speed units)A speed limit of 0 means unlimited speed
acceleration_model ACC_MODEL_RAIL, ACC_MODEL_MONORAIL, ACC_MODEL_MAGLEVACC_MODEL_RAIL and ACC_MODEL_MONORAIL behave the same currently
map_colour 0 ... 255entry in the colour palette. Since OpenTTD r19307
requires_railtype_list list of railtype labelsList of rail types on that need to be available to the company of the player for this rail type to be introduced at (or after) the introduction date. This limit does not apply when the rail type is introduced by the introduction of a vehicle. Since OpenTTD r21842
introduces_railtype_listlist of railtype labelsList of rail types that get introduced when this rail type is introduced. For example, to make sure that when a fast rail type is introduced the slow variant exists. Since OpenTTD r21841
sort_order 0 ... 255number which defines the sort order among rail types. If this entry is not defined, it gets assinged sort order n*10+7 for the n-th railtype. Since OpenTTD r21866

Sort order

The sort_order influences the sort order of the drop down lists with rail types. Default values are as follows:

ValueMeaning
07 normal rail
17 electrified rail
27 monorail
37 maglev
n7 railtype #n
Thus the rail type that (internally) gets index 8 will get a default value of 87. These defaults are to keep the ordering when this property is not supported as they were.

Base speeds for curves

The base speeds relevant for the curve_speed_multiplier are:

curve lengthbase speed [km/h]
0 (90 degree turn)30
144
255
366
475
584
691
798
8103
9108
10111
11114
12+115

Graphics blocks for railtypes

Rail types define a number of fixed graphic blocks:

block namenumber of spritesmeaning
gui 164 rail directions, autorail, depot, tunnel and convert rail sprites for rail menu
track_overlay*106 flat and 4 slope sprites. Track without landscape
underlay* 166 flat and 4 slope, one crossing WITH track, 5 junction pieces without track. Tracks with foundations but without landscape
tunnels* 44 track sprites, one for each tunnel entrance. Only track with foundations, no landscape
catenary_wire28
catenary_pylons8
bridge_surfaces6
level_crossings*10For each direction: one track sprite and 4 sprites for road lights etc
depots*62 sprites for each south-ish, 1 sprite for each north-ish depot. Like original depots.
fences8x, y, vertical, horizontal, SW, SE, NE and NW slopes like original fences at sprite 1301

The entries marked by * are required. A typical implementation for railtypes can look like

item(FEAT_RAILTYPES, elrail, 0x01) {
    property {
        label:                      "SHIN";
        name:                       string(STR_EL_RAIL);
        menu_text:                  string(STR_EL_RAIL);
        build_window_caption:       string(STR_BUILD_CAPTION);
        autoreplace_text:           string(STR_AUTOREPLACE);
        new_engine_text:            string(STR_NEW_ENGINE);
        compatile_railtype_list:    ["SHIN","RAIL","ELRL"];           // Tracks of rail and electrified rail are compatible
        powered_railtype_list:      ["ELRL","SHIN"];                  // But we got only power when we have electricity
        railtype_flags:             RAILTYPE_FLAG_CATANERY;           // High speed tracks should not have level crossings
        curve_speed_multiplier:     1;
        station_graphics:           RAILTYPE_STATION_MAGLEV;          // We want the most modern stations
        construction_cost:          32;                               // should be pretty steep
        speed_limit:                500 km/h;
        acceleration_model:         ACC_MODEL_RAIL;                   // This is still rail, though
    }
    graphics {
        track_overlay:   ground_switch_overlay;     // defines the sprites drawn as overlay for junctions and highlight
        underlay:        ground_switch_underlay;    // defines the usual tracks and the underlay for junctions
        level_crossings: level_crossing_switch;     // defines level crossings including traffic lights and blocking bars
        tunnels:         tunnel_switch;             // defines the tracks drawn on a funnel tile
        depots:          depot_switch_electric;     // defines the depot sprites
        brdige_surfaces: bridge_terrain_switch;     // defines the overlay drawn over bridges
        fences:          fences_group;              // defines the look of fences
        // we don't define catenery wire and pylons, thus we use the default which comes with the base graphics.
    }
}
The switches and graphics blocks are defined in the usual way as described in sections switches, random switches and graphics block sections.