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: 9432
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: 25
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: 25
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 8349 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: 9432
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
Traffic Manager
Traffic Manager
Posts: 190
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
I have Asperger's, please be easy on me about stuff. My apologies if I've been a problem for you in the past.
User avatar
stefino_cz
Transport Coordinator
Transport Coordinator
Posts: 268
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: 23
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
Transport Coordinator
Transport Coordinator
Posts: 268
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
Route Supervisor
Route Supervisor
Posts: 490
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
Transport Coordinator
Transport Coordinator
Posts: 268
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
User avatar
Chrill
Moderator
Moderator
Posts: 15972
Joined: 18 Dec 2004 17:35
Location: Stockholm, Sweden
Contact:

Re: NML - a Newgrf Meta Language

Post by Chrill »

I've updated the first post to link here instead:
https://github.com/OpenTTD/nml/releases
Image
My Scenarios:
Archipiélago Hermoso (Latest Release: Version 3.2)
Turnpike Falls (Latest Release: Version 0.91)
Sunmannus
Engineer
Engineer
Posts: 25
Joined: 09 Aug 2013 06:31

Re: NML - a Newgrf Meta Language

Post 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
Image
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post 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
Sunmannus
Engineer
Engineer
Posts: 25
Joined: 09 Aug 2013 06:31

Re: NML - a Newgrf Meta Language

Post by Sunmannus »

McZapkie wrote: 05 Jun 2021 14:01 Here is a simple example:
https://dev.openttdcoop.org/projects/ec ... orage.pnml
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.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

Yes, you need to have separate tiles for separate cargo to switch them on/off.
trexxet
Engineer
Engineer
Posts: 7
Joined: 28 May 2021 12:10

Re: NML - a Newgrf Meta Language

Post 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?
Attachments
ktm5m3.png
ktm5m3.png (9.73 KiB) Viewed 4483 times
2ktm5.PNG
2ktm5.PNG (9.49 KiB) Viewed 4483 times
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

You need to add third part, invisible.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests