NewGRF Debugging

From OpenTTD
Jump to: navigation, search



Feature availability

<1.0

1.0-1.2

1.3

1.4

1.5-1.7

Nightly

Contents

Activating newgrf developer tools

OpenTTD r19723 and following introduced a number of debugging tools for (New)GRF developers. In order to make them accessible the debugging tools need to be activated via a hidden setting, best via console:

set newgrf_developer_tools 1

Then a number of tools become available

Sprite alignment tool

A simple sprite alignment helper available from the 'Information' menu on the main toolbar.

The sprite alignment tool does not store the new offsets anywhere so as soon as the sprite is reloaded the offsets are gone (use a bigger sprite cache if this happens). Also anything that reloads NewGRFs (new games, loading games or (re)applying NewGRFs) clears the sprite cache and as such resets the offsets.

A 'picker' is included to help you find the sprite you need. This will list the sprites used at a particular screen location, try each item in the list until you find the one you are looking for.

Accessing the sprite alignment tool

Sprite aligner 1.png


The sprite alignment tool in use

Sprite aligner 2.png

Variable / Property inspection tool

A debug tool for variables and properties is provided. A wide range of variables and properties are included for each type of object. Some properties are not shown as they are already obvious in either in-game (for example, vehicle name), or they are obvious in the nfo for action 0.

The industry debug window includes the values of the 16 persistent storage locations. This enables industry coders to debug complex varation to chains by pushing values to storage (only possible for industries, vehicles, houses etc. have no persistent storage).

The debug view for variables can be accessed via the tile area information tool for all newgrfs which don't deal with vehicles (note the debug icon in the upper right of the area information window):

Variable debug1.png

Variable debug2.png


The debug for vehicle variables is accessed directly via the vehicle window. Vehicle debug.png

Bounding Box viewer

Accessible via the shortcut Ctrl+B or near the sprite alignment tool the bounding box view shows the bounding box of all sprites drawn on the map.

Reloading NewGRFs

When you quickly want to check the changes you made to a NewGRF you can make use of the console command

reload_newgrfs

It will re-initialize all NewGRFs of the current game from their grf files. Thus you can overwrite your grf with a new version and use this command to immediately review the changes you made.

Note that it undoes all sprite alignment changes made with the sprite alignment tool and that it will only re-read the exact grf files which are currently used - thus you need to overwrite the grf to see changes. Putting a new version in another file will not do the trick.

Loading older versions of NewGRFs

For testing purposes or when creating maps for actual long-term playing it may sometimes be convenient to not use the bleeding edge version of the NewGRF(s) you develop but the latest stable - or maybe another version which simply works differently. Use

set newgrf_show_old_versions 1

to have OpenTTD show all distinct versions of all NewGRFs in the NewGRF selection dialogues.

Personal tools