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.
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
The sprite alignment tool in use
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):
The debug for vehicle variables is accessed directly via the vehicle window.
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.
When you quickly want to check the changes you made to a NewGRF you can make use of the console command
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.