The m4nfo User manual and Technical Report

Technical Report

Train properties, functions and callbacks


Content

Road vehicle property functions

m4nfo road vehicle properties are based on plain nfo's action0 properties. Most of them are mapped in a straightforward way, but some of m4nfo's road vehicle property functions are based on custom calculations, or based on using more than one nfo property.

m4nfo function nfo property custom
airdrag0x19 
callbacks0x17yes
capacity0x0F 
cargoaging0x22
cargoclasses0x1D + 0x1Eyes
cargolist0x24 + 0x25 
cargomask0x16
cargotype0x10
climate0x06
effort0x18yes
flags0x1C 
intro0x00 + 0x1Fyes
loadamount0x07 
modlife0x04
newgraphics0x0E
power0x13yes
price0x11 
refitcost0x1Ayes
reliability0x02 
retire0x1B
runningcost0x09
soundeffect0x12
sortbefore0x20
speed0x08yes
vehlife0x03 
weight0x14

Flag label Bit Value
TRAMTRACK00x01
2CC10x02
AUTOREFITTING20x04
CARGOMULTIPLIER30x08
NOBRKEFFECT40x10

callbacks(<List::Callbacks>)

Enabling callbacks in plain nfo means to set bits in property (0x17). Unfortunately, these bits have no numerical relation to the corresponding callback values returned by nfo's variable (0x0C). In m4nfo, both property function callbacks() and performance function callback() are using the same callback labels.

cargoclasses(<List::(+|-)CargoClass>)

This m4nfo property function combines the two nfo properties for cargo class inclusion (0x1D) and exclusion (0x1E).

effort(<Unit-term>)

Plain nfo handles tractive effort as a coefficient. It sets what fraction of the vehicle weight is equal to the maximum tractive effort. The default value of 0x4C represents a friction coefficient of ยต = 0.3.

m4nfo property function effort() takes a real tractive effort value, given either in [kn, KN, kp, KP, lbf, LBF], and re-calculates the nfo coefficient by taking into account the engine's weight.

If the engine's weight has not been specified at the time of this function's call, error message ERR_NOWEIGHT is shown.

intro(<Date>)

Unline nfo, which again uses two properties for the introduction date (0x00 and 0x1F), this m4nfo function takes an introduction date in different formats and re-formats it for the appropriate nfo properties, i.e. if the given year is after 1920, only nfo property 0x00 will be used.

power(<Unit-term>)

Plain nfo allows to specify the power of an engine in 'hp' only, but m4nfo allows to use either [hp, HP, ps, PS, kw, KW].

refitcost(<Byte> | <Unit-term>)

In m4nfo, the refit cost can be given either as a Byte value, with its maximum value "255" correlating to 50% of the vehicle's purchase price cost base (this is the original nfo behaviour), or directly as a percent value.

speed(<Unit-term>)

Plain nfo allows to specify the speed of an road vehicle in units of mph*3.2, i.e. approximately km/h only, but m4nfo allows to use either [km/h, KM/H, mph, MPH].

Road vehicle performance functions

m4nfo road vehicle performance functions are based on plain nfo's Variational Action2 variables. Again, most of them are mapped in a straightforward way, but some of m4nfo's road vehicle performance functions are based on custom calculations, or based on use of more than one nfo variable.

Please note that functions return either Byte, Word or Dword values, depending on the context they're used in.

m4nfo function nfo var Byte Word/Dword
ageindays0xC0 85/86 C0 00 FF FF
ageinyears0x24/0x4985/86 (custom)
animation0x4682 46 08 03 
articulated0x1081 10 00 FF
autoreplace81 10 00 FF
callback0x0C81 0C 00 FF85 0C 00 FF FF
cargo0xB981 B9 00 FF 
cnst_cargo0x4281/82 42 08 FF 
cnst_cargoclasses81/82 42 xx FF
cnst_refit81/82 42 10 FF
current_capacity0xBA 85 BA 00 FF FF
current_load0xBC85 BC 00 FF FF
current_speed0xB485 B4 00 FF FF
daysintravel0xF085 F0 00 FF FF
dayspastservice0x23/0x4B(custom)
direction0x9F81 9F 00 FF 
displaymode0x1081 10 00 FF
elsen/a 
flipped0xC881/82 C8 00 FF
idcount0x6081/82 60 00 FF (*)
indepot0xE282 E2 00 FF
islast0xDA81 DA 00 FF
lastmaintenance0x92 85/86 92 00 FF FF
lastservicedate0x4B89/8A 4B 00 FF FF FF FF
lastserviceyear(custom)
loadtime0x90 85 90 00 FF FF
maxspeed0x9885 98 00 FF FF
property0x1081 10 00 FF 
randombits0x5F81/82 5F 08 FF (*)
randomtriggers81/82 5F 00 FF (*)
rcost_cargotype0x1081 10 00 FF
rcost_cargosubtype81 10 08 FF
rcost_cargoclass81 10 10 FF
refitted0xF281/82 F2 00 FF
reliabilitystate0xCE 85 CE 00 FF FF
servint0x9485 94 00 FF FF
soundevent0x1081 10 00 FF 
speedlimit0xF4 86 F4 00 FF FF
veh_cargoclass0x4781 47 10 FF 
veh_cargotype81/82 47 00 FF
veh_cargoweight81 47 08 FF
veh_currentload0xBC81 BC 00 FF
veh_getinfo0x61(custom) (*)
veh_getinfoabs(custom) (*)
veh_id0xC681/82 C6 00 FF 
veh_marketinfo0x4881/82 48 00 07
veh_num0x4081/82 40 10 FF
veh_posrel0x41 81/82 41
veh_posabs0x40 81/82 40
veh_status0xB281 B2 00 FF
veh_zpos0x9E81/82 9E 00 FF
yearbuilt0x49 85/86 49 00 FF FF

(*) - may be adjusted by use of auxiliary function shiftmask(). (custom) - these functions are using more than one TTD variable and/or make use of auxiliary functions shiftmask() and/or engine().

idcount(<Veh-ID>, <block>)

veh_posrel/veh_posabs(FRONT | BACK | MOD2 | MOD3 | MOD4 | MOD6, <block>)

yearbuilt(<block>)

Road vehicle callbacks

m4nfo road vehicle callbacks are based on plain nfo's callbacks. They're all mapped in a straightforward way. Callbacks from the first section of the table below have to be enabled by property function callbacks(), but those from the second section do not need to be: they're always active and will be used automatically if needed.

m4nfo callback nfo callback
CB_ARTI0x16
CB_LOAD0x12
CB_POWR0x10
CB_RCAP0x15
CB_RCOL0x2D
CB_SOUND0x33
CB_TSFX0x19
CB_WLEN0x11
CB_ARVS0x18
CB_ATAC0x1D
CB_PROP0x36
CB_RCOST0x15E
CB_STOP0x31
CB_TEXT0x23
CB_32DAY0x32

Callback helper functions

Callback helper functions are based on m4nfo's function cbr() which returns a parameter as a callback return value.

m4nfo function definition
addvehcbr($1)
addvehrevcbr($1+0x80)
attachcbr($1)
effectcbr($1)
seteffort(custom)
autorefitcbr(eval($1 | 16384))
refsndcbr(_S_$1)
grftextcbr($1)
reftxtcb(custom)

Random functions

In nfo, randomized Action2s are used to either randomize the vehicle (0x80) nased on itself, based on the first vehicle of its consist (0x83), or based on any vehicle in the consist (0x84).

m4nfo function nfo random Action2 type
randomrel0x80
randomabs0x83
randomcount0x84