Page 65 of 65
Re: NML - a Newgrf Meta Language
Posted: 01 Dec 2019 17:40
by planetmaker
Not necessarily.
Re: NML - a Newgrf Meta Language
Posted: 02 Dec 2019 13:28
by Timaperm
It is more convenient to me through Linux ubuntu to make.
Re: NML - a Newgrf Meta Language
Posted: 27 Dec 2019 21:59
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
Re: NML - a Newgrf Meta Language
Posted: 29 Dec 2019 11:19
by Alberth
It's a Python program, so you can just take the NML source, get a Python3 interpreter, and run the code.
Re: NML - a Newgrf Meta Language
Posted: 30 Dec 2019 00:37
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 (5.29 KiB) Viewed 12338 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
&
commands before each session?
Sorry for bothering you
Re: NML - a Newgrf Meta Language
Posted: 30 Dec 2019 07:03
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.)
Re: NML - a Newgrf Meta Language
Posted: 03 Feb 2020 10:04
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:
- Install python3.6 or later
- download NML source repository
- install libraries:
- python -m pip install pillow
- python -m pip install ply
- optionally install NML as administrator from command line: python setup.py install
- execute nml from command line: python the/path/to/nmlc something.nml
Re: NML - a Newgrf Meta Language
Posted: 10 Feb 2020 00:07
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:
- Install python3.6 or later
- download NML source repository
- install libraries:
- python -m pip install pillow
- python -m pip install ply
- optionally install NML as administrator from command line: python setup.py install
- 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
Re: NML - a Newgrf Meta Language
Posted: 10 Feb 2020 11:41
by stefino_cz
Hi,
I still need a help with NML instalation. I'm able to start command
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

Re: NML - a Newgrf Meta Language
Posted: 21 Apr 2020 13:51
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!

THX
Re: NML - a Newgrf Meta Language
Posted: 03 Jul 2020 16:49
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

Re: NML - a Newgrf Meta Language
Posted: 03 Jul 2020 17:22
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.
Re: NML - a Newgrf Meta Language
Posted: 04 Jul 2020 05:06
by stefino_cz
Yeah, this is the problem. Thnaks a lot

Re: NML - a Newgrf Meta Language
Posted: 23 Dec 2020 08:45
by Chrill
I've updated the first post to link here instead:
https://github.com/OpenTTD/nml/releases
Re: NML - a Newgrf Meta Language
Posted: 05 Jun 2021 01:46
by Sunmannus
I'm trying to reimplement the stockpile limits in a fork of 3iff's SPI, but I'm having a hard time figuring out how to get it to work properly.
So, I have this industry that requires WORK and [ENSP or TOOL]. I want it to stop accepting workers (or any other cargo) if incoming_cargo_waiting("WORK") >= 40. I have established the appropriate callbacks in both the industry and tile definitions, but while it
actually stops taking new workers, it does
not allow the industry to receive any other cargo.
Any idea how to solve this?
Relevant code
- [+] Spoiler
-
For the Industrytile
Code: Select all
switch(FEAT_INDUSTRYTILES, PARENT, SWI_INDTILE_iron_ore_mine_CHECK_STOP_WORK, (incoming_cargo_waiting("WORK") > (40)) ) {
0 : return 8;
return 0; //stop
}
item(FEAT_INDUSTRYTILES, INDTILE_iron_mine_1, 112) {
property {
substitute: 0;
//special_flags: bitmask(INDTILE_FLAG_ACCEPT_ALL);
land_shape_flags: bitmask(LSF_ONLY_ON_FLAT_LAND);
accepted_cargos: [[WORK, 8], [ENSP, 8], [TOOL, 8]];
}
graphics {
cargo_amount_accept: SWI_INDTILE_iron_ore_mine_CHECK_STOP_WORK;
foundations: return CB_RESULT_NO_FOUNDATIONS;
autoslope: return CB_RESULT_NO_AUTOSLOPE;
tile_check: iron_ore_mine_tile_location_check;
SWI_iron_mine_mastergfx;
}
}
For the industry
Code: Select all
switch(FEAT_INDUSTRIES, SELF, SWI_ACCEPT_WORK, extra_callback_info2 & 0xFF) {
return 1;
}
switch(FEAT_INDUSTRIES, SELF, SWI_STOP_WORK, extra_callback_info2 & 0xFF) {
WORK : return 0; //stop accept crew
default : return 1;
}
switch(FEAT_INDUSTRIES, SELF, SWI_iron_ore_mine_CHECK_STOP_WORK, (incoming_cargo_waiting("WORK") > (40)) ) {
1 : return SWI_STOP_WORK;
return SWI_ACCEPT_WORK;
}
...
item(FEAT_INDUSTRIES, iron_ore_mine, 12) {
graphics {
stop_accept_cargo: SWI_iron_ore_mine_CHECK_STOP_WORK;
...
}
}
Screenshot
- [+] Spoiler

Re: NML - a Newgrf Meta Language
Posted: 05 Jun 2021 14:01
by Wahazar
Sunmannus wrote: 05 Jun 2021 01:46
I'm trying to reimplement the stockpile limits in a fork of 3iff's SPI, but I'm having a hard time figuring out how to get it to work properly.
Here is a simple example:
https://dev.openttdcoop.org/projects/ec ... orage.pnml
Re: NML - a Newgrf Meta Language
Posted: 06 Jun 2021 00:41
by Sunmannus
Thank you for your reply and for the link.
As far as I can see, there are no significant differences between the code in ECSext and the one I have been using as a guide (OGFX Manpower Ind and SPI). And actually, the code works (it limits the reception of the selected cargo when the stockpile limit is reached), but the problem is still that it does not allow to receive any of the other cargoes defined by that same tile.
I think I can work around the issue if I define different industry tiles for each type of cargo the industry requires, but in a set with 60+ industries receiving 3-5 raw materials on average it's not really an option. I'll give it some more thought, but if so I'll have to drop that feature.
Re: NML - a Newgrf Meta Language
Posted: 06 Jun 2021 08:23
by Wahazar
Yes, you need to have separate tiles for separate cargo to switch them on/off.
Re: NML - a Newgrf Meta Language
Posted: 16 Jun 2021 02:48
by trexxet
Hi! I'm trying to make a long tram (15m) using 3.3 px/m scale, so it's 50 px in length. Adding a second car (multiple unit), I'm facing a problem that length 8 is not enough - rear car overlaps with front one. Is there any way to fix this?
Re: NML - a Newgrf Meta Language
Posted: 16 Jun 2021 09:13
by Wahazar
You need to add third part, invisible.