Debugging
OpenTTD Manual
Installation · FAQ
Tutorials and Instructions
Game interface · README.md
Infrastructure

Railways:

Signals · Stations · Junctions · Carrying capacity · Rail Designs & Tips
Roadways · Tramways · Waterways · Airports · Landscaping
Vehicles
Trains · Road vehicles · Ships · Aircraft · Orders
Settings
Game options · Settings · AI settings · Custom graphics (NewGRF) · Sandbox options · Command line
Graphics and sound
OpenGFX · OpenMSX · OpenSFX
More topics
Climates · Towns · Industries · Economy · Disasters · Tips · Hidden features · Hotkeys · Console · Game Mechanics · Multiplayer · Scenario editor · Online content · Social Integration
Troubleshooting · Links
Feature availability
<1.0
1.0-1.2
1.3
1.4
1.5-12.0
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.

TIPS:
1. There's a bug with the sprite aligner. When using it to align anything, divide the result by 4.
Example: when you have aligned your sprite to your satisfaction, and it says X offset: -24, Y offset: -44, that means that in your .nml file, the actual offsets will be X: -6 and Y: -11

2. CTRL + click will move the sprite by 8 pixels (2 pixels on the actual spritesheet). Always make sure to move your sprite in 4 pixel increments

Accessing the sprite alignment tool

/File/en/Development/NewGRF/Sprite aligner 1.png

The sprite alignment tool in use

/File/en/Development/NewGRF/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):

/File/en/Development/NewGRF/Variable debug1.png

/File/en/Development/NewGRF/Variable debug2.png

The debug for vehicle variables is accessed directly via the vehicle window. /File/en/Development/NewGRF/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.