The code for a ship consists of three parts:
The definition sets the properties of the ship like introduction date, speed, capacity, etc. Please note that a vehicle definition may only occur after a prior grfinit() function call for the grf file.
The ship 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 ship's activation function (performance functions).
The ship activation instantiates the ship by finally assigning graphics sets and/or callback or other variable-referencing functions to this particular ship. This is done by supplying a block of special functions handling references and cargo types to the ship's activation. See below.
| Function | Meaning |
| defineship(<Veh-ID>,<block>) | Ship definition |
| nameship(<Veh-ID>, {<Language-ID>, <String>}) | Definition of ship name(s) |
| makeship(<Veh-ID<,<block<) | Ship activation |
This function defines a ship. Its parameters are the ship's ID, an optional standard text naming the ship, and a block of property-defining functions, where the relative position of the property functions is irrelevant.
defineship(_HARLAND,{""},
intro(1968)
climate(TEMPERATE, ARCTIC, TROPIC)
newgraphics()
refittable(YES)
price(180)
speed(40 km/h)
cargotype(MENU)
capacity(280)
loadamount(40)
runningcost(160)
soundeffect(4)
refitcost(1 %)
canalspeed(60 %)
cargoclasses(+REEF) // allow for food, fruit, fish, vegetables, milk
cargomask(FISH) // but no fish!
)
This function defines more names for a ship than the default one given by definevehicle(). It should be used if a ship needs names in more than one language. Its parameters are the ship's ID and a block consisting of language IDs and associated names.
nameship(_HARLAND, ALL, "'Harland' Reefer", D, "Kühlschiff 'Harland'", F, "Navire frigorifique 'Harland'", E, "Buque frigorífico 'Harland'", I, "Nave frigorifera 'Harland'" )
This function activates a previously defined ship. Its parameters are the ship's ID and a block of special cargo-associated functions:
| Function | Meaning |
| Linking a chain of graphics or variable-dependencies to this ship | |
| default(<ref()>) | Default chain to use with this ship |
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.
makeship(_FLENDER, link(ref(1),FOOD, FRUT) default(ref(4)) // GOOD (container, refrigerated) )