In m4nfo, canals and rivers are using only two types of functions:
Functions for sprite layout definition
The sprite layout for canals/rivers is very simple:
def(3) spriteset(0) // normal def(4) spriteset(1) // snow
Functions for canal/river performance
These functions are used to evaluate game-intrinsic variables, and make them accessible to the canal/river's activation function. They are available for canal/river IDs CR_CLIFF (water cliffs), CR_LOCK (locks), CR_DIKE (canal banks), CR_SLOPE (river slopes), and CR_BANK (river banks).
| Function | Description |
| tinfo_terrain(<block>) | Terrain type: "0" = normal, "1" = desert, "2" = rainforest, "4" = on or above snowline. |
| tinfo_height(<block>) | Height above ground |
| randomrel(0, <randombit> <list::ref()>) | Get random reference |
def(6) tinfo_terrain( ref(4) if(SNOW) ref(3) else )
randomrel(<trigger>, <randombit> <List::ref()>)
Unlike the performance functions above, whose results are always determined by a predictable decision, one can also use random functions to pick one of several graphics sets or callback results.
There are no triggers for canals/rivers, hence you must always define 0 (or CONSTRUCT).
Setting randombit determines the first bit to be re-randomized, as well as basing the random graphics on. The total number of bits used is the 2-logarithm of the number of references used, e.g., for 16 references, 4 bits are used.
Canals/rivers have 8 random bits.
The number of referenced sets to choose from must be a power of 2, i.e. 2, 4, 8, 16 etc.