NFO - questions & answers

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

NFO - questions & answers

Post by TadeuszD »

NML is great tool for creating NewGRFs, but now it does not support all features, stations for example. So, I need start to learn NFO... :)
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
It may also be interesting to look at the NFO of NFO-based projects like HEQS or 2ccTrainSet - or maybe the early revisions of OpenGFX+ Airports (airportsplus); they can be browsed online, too. For instance this only has action3, action2 and action1 (action0 is missing as it re-uses the default defined tile and changes nothing there).

Questions & answers
TadeuszD wrote:- what is the <Sprite-number> in every action 'block'? Many actions does not need any sprites.
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.
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?
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 can I 'construct' expressions inside varactions block? What is the meaning of special variables 40+x, 60+x and 80+x?
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
I'm trying to understand Dutch Stations Set, but analysing hex codes is hard to me...
Let's look at a simple one: http://dev.openttdcoop.org/projects/dut ... dings.hnfo
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
<sprite-num> * <sprite length in bytes> <Action 01> <Feature 04 = Stations> <Num sets: 1> <Length of sets: 16 real sprites>
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
<spritenum> * <sprite length> <Action2> <Feature 04> <This is ID 06>

Code: Select all

  81 41
<check lowest byte> <of variable 41>

Code: Select all

80 0F 00 04
<shift and add modulo adjust> <mask with 0x0F> <add 0> <modulo 4>

Code: Select all

  01
<check on result range>

Code: Select all

05 00  02 02
<for the range of 2 ... 2 goto sprite with ID 05 (it's the action2 above this)>

Code: Select all

04 00
<goto sprite with ID 04 otherwise (it's the action2 two lines above this)>

Line 85 has the Action3 which links the action0 to the real sprites via action2s:

Code: Select all

10 * 10	 03 04 01
<spritenum> * <sprite length> <Action3> <Feature 04> <This is for one ID only>

Code: Select all

ID_HILVERSUM
this is actually a number after pre-processing in this set. It is the ID of the station tile

Code: Select all

 01
One "cargo" type will be distinguished

Code: Select all

FE 09 00
<cargo '0xFE'> <use sprite with ID 0x09 --> action2, line 83>

Code: Select all

00 00
default: use sprite with ID 0x00 --> action2, line 69

Line 86 has an Action4 which associates text with a textID

Code: Select all

10 * 10	 04 48 81 01
<spritenum> * <sprite length> <Action4> <Feature 48 = original strings> <English UK> <One string follows>

Code: Select all

ID_HILVERSUM C5
ID Of the text string. ID_HILVERSUM is actually a number after pre-processing in this set.

Code: Select all

"Hilversum" 00
The actual string 0-terminated

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
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 6 guests