
Greatly helped me planetmaker who answered many of my questions. In this thread I published some quotes from our PMs. I hope this thread will be usefull for other NFO beginers.

Usefull links:
http://newgrf-specs.tt-wiki.net/wiki/Main_Page - official NewGRF spec
http://www.tt-wiki.net/wiki/Tutorials - tt-wiki tutorials
Older links (some details can be out-of-dated), but still useful:
http://users.tt-forums.net/pikka/wiki/i ... GRF_coding
Quick overview of NFO syntax:
NFO has not exactly blocks but,works in a way that:
* real sprites are defined in action1 and assigned an ID
* subsequently you define a sequence of action2 (any type of switch block in NML), action3 (the graphics block in NML) , action0 (the property block in NML) as suits your needs. You chain them by referring to the ID of the respective sprite. You can re-use IDs as the sprite which defines an ID last is the jump destination if its ID is referenced in a later sprite. A single action2 always takes one variable, possibly modifies it by a single operation and then allows to jump to another action2 (or an action1, a real sprite) depending on the result of that operation.
Things like tile layouts, they're all part of the action0. But like you can have in NML several item blocks, you can have several action0 sprites in NFO which define different properties.
If you fancy, you can easily use nmlc itself to compare the NML and its equivalent in NFO by having it output NFO directly. If you comment the NML appropriately and use good switch and item names you likely can follow the NFO as comments and names are retained:
Code: Select all
nmlc --nfo blah.nfo blah.nml
Questions & answers
Think of it like in the old BASIC times. Sprite numbers are just numbers which sequentially number... sprites. nforenum does that for you. And grfcodec will only warn on wrong numbers anyway.TadeuszD wrote:- what is the <Sprite-number> in every action 'block'? Many actions does not need any sprites.
The simple answer is: you choose the IDs. Define them in-place where needed. They're not defined elsewhere. They're NFO's equivalent to NML's block names.how I can 'connect' a few properties, callbacks and varactions to one vehicle/object/etc.? In Action3? OK, but where the <ids...> and <set-ID> are defined?
You do the calculations varaction2 by varaction2. Chaining them as needed. NML allows there MUCH more concise and legible constructs. variablbles 40+x are variables relating to the state of the thing you define (e.g. the vehicle or station tile), 60+x are the variables of the state of the related object you define (e.g. the lead engine or station). 80+x are ... other variables, e.g. see this list of station tile variables- how can I 'construct' expressions inside varactions block? What is the meaning of special variables 40+x, 60+x and 80+x?
Let's look at a simple one: http://dev.openttdcoop.org/projects/dut ... dings.hnfoI'm trying to understand Dutch Stations Set, but analysing hex codes is hard to me...
Lines 1 - 32 define the real sprites. It's one Action1 with 16 real sprites defined. Line 4:
Code: Select all
10 * 10 01 04 01 16
You can ignore the part which is striked through. It's automatically adjusted by nforenum, thus not correct there.
Lines 33-64 define the Action0 of that station. For stations that's the interesting part as it contains the tile layout
(...)
Lines 69-83 are different Action2. In this case it's a varaction2:
Code: Select all
10 * 10 02 04 06
Code: Select all
81 41
Code: Select all
80 0F 00 04
Code: Select all
01
Code: Select all
05 00 02 02
Code: Select all
04 00
Line 85 has the Action3 which links the action0 to the real sprites via action2s:
Code: Select all
10 * 10 03 04 01
Code: Select all
ID_HILVERSUM
Code: Select all
01
Code: Select all
FE 09 00
Code: Select all
00 00
Line 86 has an Action4 which associates text with a textID
Code: Select all
10 * 10 04 48 81 01
Code: Select all
ID_HILVERSUM C5
Code: Select all
"Hilversum" 00
Under a proper license and better commented is the code of CHIPS, e.g. http://dev.openttdcoop.org/projects/chi ... fices.pnfo is an even simpler example with also a nicely commented action0