The m4nfo User manual and Technical Report

Cargoes

Defining properties for and handling of cargoes

Introduction

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.

Functions

FunctionMeaning
definecargo(<Cargo-ID>, <block>)Cargo definition
makecargo(<Cargo-ID>, <List::ref()>)Cargo activation

Description

definecargo(<Cargo-ID>, <block>)

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.

Example (defining new cargo 'fish'):
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:

Example (new cargo 'fish'):
makecargo(FISH, ref(30))