The code for a road vehicle consists of three parts:
The definition sets the properties of the road vehicle like introduction date, top speed, capacity, etc. Please note that a vehicle definition may only occur after a prior grfinit() function call for the grf file.
The road vehicle's performance functions are used to group sets of graphics sprites from a previous spriteblock() (layout functions), or to evaluate game-intrinsic variables, and make both of them accessible to the vehicle's activation function (performance functions).
The vehicle activation instantiates the vehicle by finally assigning graphics sets and/or callback or other variable-referencing functions to this particular vehicle. This is done by supplying a block of special functions handling references and cargo types to the vehicle's activation. See below.
| Function | Meaning |
| definevehicle(<Veh-ID>, List::(<Language-ID>, <String>) | <String>,<block>) | Road vehicle definition |
| namevehicle(<Veh-ID>, List::(<Language-ID>, <String>)) | Definition of road vehicle's name(s) |
| makevehicle(<Veh-ID<, <block<) | Road vehicle activation |
This function defines a road vehicle. Its parameters are the road vehicle's ID, an optional standard text naming the vehicle (or a namevehicle block, s.b.), and a block of property-defining functions, where the relative position of the property functions is irrelevant.
definevehicle(_BÜSSING_NAGD2,{"Büssing-NAG D2"},
intro(1928)
reliability(22)
vehlife(16)
modlife(21)
loadamount(11)
climate(TEMPERATE, ARCTIC, TROPIC)
speed(55 km/h)
runningcost(18)
runningcostbase(0x4c48)
newgraphics()
capacity(61)
cargotype(PASS)
price(17)
soundeffect(BUS_START)
power(70 PS)
weight(7 t)
cargomask(NONE)
callbacks(CB_WLEN)
effort(15 KN)
airdrag(0)
retire(7)
flags(2CC)
cargoclasses(+PASS)
)
This function defines more names for a road vehicle than the default one given by definevehicle(). It should be used if a road vehicle needs names in more than one language. Its parameters are the road vehicle's ID and a block consisting of language IDs and associated names.
See example in the trains section.
Alternatively, you may use a namevehicle block as the second parameter for function definevehicle(). This might be beneficial in situations where a vehicle's name would be different in a number of languages, and those would be stored in an extra file, to keep them together, see example in the trains section.
makevehicle(<Veh-ID<, <block<)
This function activates a previously defined road vehicle. Its parameters are the road vehicle's ID and a block of special cargo-associated functions:
| Function | Meaning |
| Linking a chain of graphics or variable-dependencies to this vehicle | |
| default(<ref()>) | Default chain to use with this vehicle |
This function links a reference to a chain of functions describing graphics and/or variable evaluations with a particular cargo type. Its parameters are the reference to the chain of functions and a cargo type.
The given cargo-type determines the set of graphics or the variable chain to be used with this particular type of cargo. If the grf file has installed a cargo translation table, the cargo type here refers to the cargo with that label in the translation table.
The special cargo-type MENU is used for graphics shown in the purchase or construction window.
This function is used if no entry from the link() function(s) matches, or if there are no special cargo-types listed at all in a link() function.