NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

Not necessarily.

Timaperm
Engineer
Engineer
Posts: 3
Joined: 01 Dec 2019 15:38

Re: NML - a Newgrf Meta Language

Post by Timaperm »

It is more convenient to me through Linux ubuntu to make.

Sunmannus
Engineer
Engineer
Posts: 21
Joined: 09 Aug 2013 06:31

Re: NML - a Newgrf Meta Language

Post by Sunmannus »

hi, anyone kindly enough to provide me a win32 build of nml 0.5.X ?. I want to try some of its new features (16-cargo industry support) but I'm unable to compile it myself.

Many thanks

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML - a Newgrf Meta Language

Post by Alberth »

It's a Python program, so you can just take the NML source, get a Python3 interpreter, and run the code.
Being a retired OpenTTD developer does not mean I know what I am doing.

Sunmannus
Engineer
Engineer
Posts: 21
Joined: 09 Aug 2013 06:31

Re: NML - a Newgrf Meta Language

Post by Sunmannus »

Alberth wrote:
29 Dec 2019 11:19
It's a Python program, so you can just take the NML source, get a Python3 interpreter, and run the code.
nml.png
nml.png (5.29 KiB) Viewed 2179 times
I think I managed to install it, but... ehmm, I'm not sure how to use it now.


I have to move my entire newgrf project folder to this directory from now on?
Also, I have to re-install it every time? I mean, write the

Code: Select all

pip3 install nml
&

Code: Select all

python setup.py install
commands before each session?

Sorry for bothering you

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML - a Newgrf Meta Language

Post by Alberth »

I think I managed to install it, but... ehmm, I'm not sure how to use it now.
The most basic form is to specify an .nml file that you want compiled, as in

Code: Select all

python the/path/to/nmlc something.nml
If the nml code is correct, this will give you a .grf file.
nml has more options to steer it, try "nmlc --help" for more options you can specify (although most are quite exotic except for the --grf option, but you get that by default already, no need to specify it).

Obviously, typing that "python the/path/to/nmlc something.nml" commandline everytime you want to compile an nml file is a hassle, so make a .bat file with that line in it, and run that .bat file instead. If you have spaces in filenames or paths with spaces in them, surround them with double quotes (or remove the spaces from the name). Nowadays, Windows has powershell as well, so that is another way to achieve less typing. No clue how that works though, last time I used a Windows system was in the previous century.

The "pip" and "python setup install" commands are for installing the stuff, you only need to do that once (I have no idea what it does at a Windows system, but Python tends to have adequate docunentation, so try your chances there if you want to know.)
Being a retired OpenTTD developer does not mean I know what I am doing.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

As a quick summary as to what currently should get you going with NML, also on windows as on any other system:

NML is a python programme and as such does not need being compiled for any operating system - you will always be fine by installing python on your system and then executing setup.py from the nml repository. See also the three posting above here

Basically:
  1. Install python3.6 or later
  2. download NML source repository
  3. install libraries:
    • python -m pip install pillow
    • python -m pip install ply
  4. optionally install NML as administrator from command line: python setup.py install
  5. execute nml from command line: python the/path/to/nmlc something.nml

User avatar
Gadg8eer
Engineer
Engineer
Posts: 103
Joined: 14 Dec 2019 14:22

Re: NML - a Newgrf Meta Language

Post by Gadg8eer »

planetmaker wrote:
03 Feb 2020 10:04
As a quick summary as to what currently should get you going with NML, also on windows as on any other system:

NML is a python programme and as such does not need being compiled for any operating system - you will always be fine by installing python on your system and then executing setup.py from the nml repository. See also the three posting above here

Basically:
  1. Install python3.6 or later
  2. download NML source repository
  3. install libraries:
    • python -m pip install pillow
    • python -m pip install ply
  4. optionally install NML as administrator from command line: python setup.py install
  5. execute nml from command line: python the/path/to/nmlc something.nml
This is an example, in case someone needs to know how to do that last step...

Code: Select all

python C:\TTDTools\NML\nmlc C:\TTDTools\GRFs\GRRS\source\src\grrs.nml

User avatar
stefino_cz
Traffic Manager
Traffic Manager
Posts: 250
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: NML - a Newgrf Meta Language

Post by stefino_cz »

Hi,
I still need a help with NML instalation. I'm able to start command

Code: Select all

setup.py install
but in the end I get information that libraries are not installed. So I tried start cmd, moved to NML master folder and set

Code: Select all

python -m pip install pillow
or
python -m pip install ply
But no result. The first what I know is, that

Code: Select all

python setup.py install
...do nothing but
setup.py install
...works with an error in the end
In case of python -m pip... I get no result (nothing happen) or information that it is unknown command (I think-not sure now). SO I think that the problem is in python but I don't know what I do wrong.

I installed python v 3.7.4 for Win 64bit. Thanks for the help :?
Image

Szurke
Engineer
Engineer
Posts: 22
Joined: 28 Aug 2014 10:56

Re: NML - a Newgrf Meta Language

Post by Szurke »

Hi guys!

Is already planned in NML for road- and railtypes can do nearby tile request too? Bw: nearby_tile_class. When don't, than pleas do it! :D THX

User avatar
stefino_cz
Traffic Manager
Traffic Manager
Posts: 250
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: NML - a Newgrf Meta Language

Post by stefino_cz »

Hi, I need help with part of industry code. When I try to compile it, this error appears

Code: Select all

nmlc ERROR: "CZTR_INDUSTRY.nml", line 2052: Syntax error, unexpected token "0"

Code: Select all

//Global bonuses

2051 //Option 1 (one year production)
2052 produce(produce_bonus_1, 0, 0, 0, current_year /100, 0);
2053
2054 //Option 2 (gradual processing)
2055 produce(produce_bonus_2,
2056 max(waiting_cargo_1 / 10, 45), max(waiting_cargo_1 / 10, 45), max(waiting_cargo_2 / 10, 45),
2057 min(waiting_cargo_1, max(waiting_cargo_1 / 10, 16)) + min(waiting_cargo_1, max(waiting_cargo_1 / 10, 16)) + min(waiting_cargo_2, max(waiting_cargo_2 / 10, 16)),
0);

//Option 3 (combination)
produce(produce_bonus_3, max(16, waiting_cargo_1 / 10), max(16, waiting_cargo_2 / 10), 0, 10 + ( ( current_year - 1850 ) /15 ) + 2*(min(16, waiting_cargo_1)) + 2*(min(16, waiting_cargo_2)), 0);
Have somebony any idea where is the problem? It's interesting that with old NML compilator it works so it seems that there is some new feature?

thanks :)
Image

User avatar
2TallTyler
Traffic Manager
Traffic Manager
Posts: 163
Joined: 11 Aug 2019 18:15
Contact:

Re: NML - a Newgrf Meta Language

Post by 2TallTyler »

Are you using NML 0.5? The syntax for the Produce block now requires square brackets which weren't present in 0.4 and before.

User avatar
stefino_cz
Traffic Manager
Traffic Manager
Posts: 250
Joined: 02 Jul 2015 08:05
Location: Czech Republic
Contact:

Re: NML - a Newgrf Meta Language

Post by stefino_cz »

2TallTyler wrote:
03 Jul 2020 17:22
Are you using NML 0.5? The syntax for the Produce block now requires square brackets which weren't present in 0.4 and before.
Yeah, this is the problem. Thnaks a lot :)
Image

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest