Newgrf Description Language (NDL)
Posted: 27 Dec 2007 20:03
This is a higher level description language that works on top of the low level NFO
Be aware that this is highly WIP, and may change significantly in a short amount of time
The general idea of a high level language is to use descriptive names instead of byte values, to help newcomers to easily learn the language, and help experienced programmers reading their own code without too many comments, so they would not have to refer to the documentation for every single byte.
USAGE:
a) this compiler is a python program, in order to run python programs, you need the python interpreter from http://www.python.org/download/
a*) there is now a windows package containing an ndl.exe, this is an awfully big file, so i still recommend to use the python files
b) this compiler generates an .nfo file, so you need grfcodec to get a .grf file
c) i assume that you are familiar with command line interfaces
d) i assume a unix style console, windows console probably needs replacing / with \
1) put your .ndl file into the "sprites" subdirectory, together with the .pcx file containing the images
2) run the ndl compiler with the command line "python ndl.py sprites/file.ndl > sprites/file.nfo", this will create the .nfo file next to the .ndl file
2*) if you unpacked the windows executable, run "ndl.exe sprites/file.ndl > sprites/file.nfo" instead
3) run "grfcodec -e file.grf" to turn the .nfo file into a .grf file
LANGUAGE SPECIFICATION:
syntax is currently related to python syntax, this is purely out of lazyness, because python ships with a python parser, and this is highly likely to change (e.g. useful would be Pascal style case-statements with ranges (12..25))
especially this means that names are case-sensitive and indentation is relevant for blocks
i will not discuss about syntax, but i take alternative suggestions in form of an implementation of a parser that generates a compatible tree-structure
[Note: i dislike XML, so don't get your hopes up, you know who you are]
Update: Version 0.2
0.1: the language allows you to specify a GrfID (Action8), and change properties of train vehicles (Action0General, Action0Trains)
0.2: allow changing graphics for vehicles, support for loading stages (Action1/2/3 for trains)
check the exampleX.ndl files for detailed descriptions
currently planned features are:
functions&callbacks (VarAction2)
embedded NFO (for anything you think you can't specify in NDL properly)
vehicle names (Action4)
more features may come while i learn NFO myself
HOW YOU CAN HELP:
i could use someone who writes up a file like TTDTrains.py for the other vehicle types.
comments and suggestions are welcome
DISCLAIMER:
this may not be useful for anything, and i will not provide a decompiler
Be aware that this is highly WIP, and may change significantly in a short amount of time
The general idea of a high level language is to use descriptive names instead of byte values, to help newcomers to easily learn the language, and help experienced programmers reading their own code without too many comments, so they would not have to refer to the documentation for every single byte.
USAGE:
a) this compiler is a python program, in order to run python programs, you need the python interpreter from http://www.python.org/download/
a*) there is now a windows package containing an ndl.exe, this is an awfully big file, so i still recommend to use the python files
b) this compiler generates an .nfo file, so you need grfcodec to get a .grf file
c) i assume that you are familiar with command line interfaces
d) i assume a unix style console, windows console probably needs replacing / with \
1) put your .ndl file into the "sprites" subdirectory, together with the .pcx file containing the images
2) run the ndl compiler with the command line "python ndl.py sprites/file.ndl > sprites/file.nfo", this will create the .nfo file next to the .ndl file
2*) if you unpacked the windows executable, run "ndl.exe sprites/file.ndl > sprites/file.nfo" instead
3) run "grfcodec -e file.grf" to turn the .nfo file into a .grf file
LANGUAGE SPECIFICATION:
syntax is currently related to python syntax, this is purely out of lazyness, because python ships with a python parser, and this is highly likely to change (e.g. useful would be Pascal style case-statements with ranges (12..25))
especially this means that names are case-sensitive and indentation is relevant for blocks
i will not discuss about syntax, but i take alternative suggestions in form of an implementation of a parser that generates a compatible tree-structure
[Note: i dislike XML, so don't get your hopes up, you know who you are]
Update: Version 0.2
0.1: the language allows you to specify a GrfID (Action8), and change properties of train vehicles (Action0General, Action0Trains)
0.2: allow changing graphics for vehicles, support for loading stages (Action1/2/3 for trains)
check the exampleX.ndl files for detailed descriptions
currently planned features are:
functions&callbacks (VarAction2)
embedded NFO (for anything you think you can't specify in NDL properly)
vehicle names (Action4)
more features may come while i learn NFO myself
HOW YOU CAN HELP:
i could use someone who writes up a file like TTDTrains.py for the other vehicle types.
comments and suggestions are welcome
DISCLAIMER:
this may not be useful for anything, and i will not provide a decompiler