NML:Parameter assignment

From GRFSpecs
Revision as of 09:14, 8 June 2026 by Rito12 (talk | contribs) (Named parameters and constants.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Block Syntax

Parameters

param[<expression>] = <expression>;

Set a parameter to the given expression. Neither of the two expressions has to be constant, the following is perfectly valid:

 param[param[2] + 1] = param[3] * param[4];

Parameters can also be named, then it is possible to access them by that name instead of index.

 custom_bit_mask = add_trains + (add_planes << 1);

Note: When assigning value to named parameter that has not been used/defined earlier it is given an unused index, therefore it is better not to mix named parameters with unnamed ones in one grf.

Compile time values

Since NML 0.7.6 it is possible to create user defined constants. They work the same way as default ones.

 const <expression> = <expression>;
 const CC_WEIRD = 12;

It is adviced to use screaming snake case for constants to distinguish them from runtime expressions.