The code for new cargoes consists of three parts:
The definition sets the feature properties of the cargo like cargo ID, cargo-related texts, weight, etc. Please note that a cargo definition may only occur after a prior grfinit() function call for the newGRF file.
The cargo's performance functions are used to group sets of graphics sprites from a previous spriteblock(), or to evaluate game-intrinsic variables, and make both of them accessible to the cargo's activation function.
The cargo activation instantiates the cargo by finally assigning graphics sets and/or callbacks to this particular cargo. This is done by supplying a block of special functions handling references and cargo types to the cargo's activation. See below.
| Function | Meaning |
| definecargo(<Cargo-ID>, <block>) | Cargo definition |
| makecargo(<Cargo-ID>, <List::ref()>) | Cargo activation |
This function defines a new cargo. Its parameters are the cargo's ID and a block of property-defining functions, where the relative position of the property functions is irrelevant.
deftxt(fishnamesingular,
US, "Fish",
UK, "Fish",
D, "Fisch",
F, "Poisson",
E, "Pesca",
I, "Pesce"
)
...
definecargo(FISH,
cargoslot(14)
typename(fishnamesingular)
unitname(fishnameplural)
unit(fishunitsingular)
units(fishunitplural)
abbrev(fishabbrev)
icon(NEWICON)
weight(16)
penalties(5,20)
price(4816)
stationcolour(161)
paymentcolour(161)
classes(EXPRESS, REEF)
label({FISH})
)
makecargo(<Cargo-ID>, <List::ref()>)
This function activates a previously defined cargo. Its parameters are a cargo-ID and a list of references. The number of references given must match the number of consecutive cargo definitions:
makecargo(FISH, ref(30))