NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

Thanks for replies, indeed, I had old 2.7 pip
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

How to downgrade to previous nml?
I made something wrong and have error:

Code: Select all

$ nmlc
Traceback (most recent call last):
  File "/usr/local/bin/nmlc", line 9, in <module>
    load_entry_point('nml==0.4.0.r5530-84d58305a9ed', 'console_scripts', 'nmlc')()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 351, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2363, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2088, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
ImportError: No module named 'nml'
even if removed by apt-get, autocleaned and installed old nml_0.2.4 which was working before, got same error.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML - a Newgrf Meta Language

Post by Alberth »

The 'nml' package needs to be available, as it contains the actual Python code of the compiler. The 'nmlc' file is just a simple 5 line wrapper script.
'available package' to Python means either to have it in the packages search path of your Python version, or have it right next to the program that you start (ie the 'nml' directory has to be right next to 'nmlc'). The latter is the case if you download the source (or clone the nml repository).

In other words, if you use the 'nmlc' that comes with the downloaded source, it will run without installing it. The simplest way to do that is by something like

Code: Select all

cd nml_project
/long/absolute/path/to/nml/repository/nmlc myproject.nml
However, typing that full path gets a bit boring after a few times. A better solution is to make 'nmlc' available in one of the standard shell PATH directories, or add a new directory to it.
I have added $HOME/bin to my PATH variable (containing all my own custom programs), and did

Code: Select all

cd $HOME/bin
ln -s /long/absolute/path/to/nml/repository/nmlc nmlc
It creates a link named $HOME/bin/nmlc that points to the nmlc program in the repository.
When I type 'nmlc', the shell looks for a program with that name using the PATH variable, finds $HOME/bin/nmlc, follows the link, and runs /long/absolute/path/to/nml/repository/nmlc .
Being a retired OpenTTD developer does not mean I know what I am doing.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

There was already nmlc wrapper in usr/local/bin, installed by nml 0.4.0 setup.py, but not working properly.
I removed it, installed old nml_0.2.4-1_all.deb and it works fine again.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

Is it possible to suppress all these "animation" (blinking pixels) warnings spam in 0.4.0 version, without forcing ---quiet for all warnings?
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

See Realsprites. Since some time warnings are given because animated pixels are often unintentional, so you need to set the ANIM flag for your sprites instead of the default NOANIM.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Graphics Workflow

Post by planetmaker »

abregado wrote:
V453000 :) wrote:What do you mean by pixel locations?
Yeah I ment the XY Offsets. Terminology fail.

I'll dig around in RAWR. Right now it seems my biggest issue is getting the nml encoder to install. First it was Python version issues and now it wont detect that I have Python Image Library installed. gah!
Try pillow instead of PIL :)

Also: why do you need to install that manually? Any linux comes with a decent packaging system, thus you just install python3, pillow and ply. On OSX you can do the same by means of macports or brew. And for windows there are pre-compiled binaries of nml.
abregado
Engineer
Engineer
Posts: 35
Joined: 02 Apr 2015 22:39

Re: Graphics Workflow

Post by abregado »

planetmaker wrote: Also: why do you need to install that manually? Any linux comes with a decent packaging system, thus you just install python3, pillow and ply. On OSX you can do the same by means of macports or brew. And for windows there are pre-compiled binaries of nml.
Im kinda new to Ubuntu/unix. It seems that I have several versions of python installed 2.6/2.7/3.2/3.4 and regardless of which interpreter I choose to run setup.py with it tells me I dont have the right version. I guess it is detecting the default version of the python executable (2.7)

So Im trying some other solutions with virtualenv but this is failing as pip doesn't seem to find ply and pillow in the package repos (tells me those are not valid package names)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Graphics Workflow

Post by planetmaker »

abregado wrote:
planetmaker wrote: Also: why do you need to install that manually? Any linux comes with a decent packaging system, thus you just install python3, pillow and ply. On OSX you can do the same by means of macports or brew. And for windows there are pre-compiled binaries of nml.
Im kinda new to Ubuntu/unix. It seems that I have several versions of python installed 2.6/2.7/3.2/3.4 and regardless of which interpreter I choose to run setup.py with it tells me I dont have the right version. I guess it is detecting the default version of the python executable (2.7)

So Im trying some other solutions with virtualenv but this is failing as pip doesn't seem to find ply and pillow in the package repos (tells me those are not valid package names)
maybe there is no pillow or pil for python3 in your repositories. If so, install it using pip (use the pip for the proper version, thus either 3.2 or 3.4, whatever is your default python3; check by looking at what python it points to:

Code: Select all

ls -l /usr/bin/python3
Default pip might only install for python 2.7 - something you don't need / want here. Assuming python3.2 is your default python3, install could look like:

Code: Select all

sudo apt-get install python3
sudo apt-get install python3-ply
sudo apt-get install python3-pip
sudo /usr/bin/pip-3.2 install pillow
User avatar
te_lanus
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 19 Jul 2012 18:04
Location: The Elizabeth Arkham Asylum for the Criminally Insane

Re: NML - a Newgrf Meta Language

Post by te_lanus »

Just a quick question. what's the longest townname allowed in NML/OpenTTD?

We've got one in South Africa that I added that might be way too long, as it seems not to show. It's Tweebuffelsmeteenskootmorsdoodgeskietfontein it's a very small town.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML - a Newgrf Meta Language

Post by Alberth »

No idea, did you try renaming an existing town?
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
te_lanus
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 19 Jul 2012 18:04
Location: The Elizabeth Arkham Asylum for the Criminally Insane

Re: NML - a Newgrf Meta Language

Post by te_lanus »

Alberth wrote:No idea, did you try renaming an existing town?
Did it this morning and seems the max number of letters for a town name is 31.
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

te_lanus wrote:Tweebuffelsmeteenskootmorsdoodgeskietfontein
At least the name is very descriptive.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
abregado
Engineer
Engineer
Posts: 35
Joined: 02 Apr 2015 22:39

Re: Graphics Workflow

Post by abregado »

right well that got me through the nml install.
Now when I use nmlc it throws an error 'no module named nml'

Code: Select all

Traceback (most recent call last):
  File "/usr/local/bin/nmlc", line 9, in <module>
    load_entry_point('nml==0.4.0.r5576M-84560317b163', 'console_scripts', 'nmlc')()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 351, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2363, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2088, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
ImportError: No module named 'nml'
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Graphics Workflow

Post by planetmaker »

abregado wrote:right well that got me through the nml install.
Now when I use nmlc it throws an error 'no module named nml'

Code: Select all

Traceback (most recent call last):
  File "/usr/local/bin/nmlc", line 9, in <module>
    load_entry_point('nml==0.4.0.r5576M-84560317b163', 'console_scripts', 'nmlc')()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 351, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2363, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2088, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
ImportError: No module named 'nml'
Can you try whether the lastest development build works better for you? (and why is it announced as modified?) There are / were some issues with packaging.

http://bundles.openttdcoop.org/nml/push/LATEST/
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

I had similar issue described by abregado.
Creating nmlc symlink in /usr/local/bin (or whenever nmlc was installed) pointing to real folder where *nmlc executable file exist (and ohter nml files and dirs), solved problem, if I remember correctly.

Question from a different kettle of fish:
according to http://newgrf-specs.tt-wiki.net/wiki/NML:Houses, there is house cargo_production callback: "The return value specifies what cargo and what amount is produced."
Is it possible to use such callback to define other cargo than mail or passengers, to produce? For example food produced by outskirts houses?
Similar question: is it possible, for multi-tile house, using cargo_type_accept callback, to accept more than 3 types of cargo per whole house?
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

McZapkie wrote:Question from a different kettle of fish:
according to http://newgrf-specs.tt-wiki.net/wiki/NML:Houses, there is house cargo_production callback: "The return value specifies what cargo and what amount is produced."
Is it possible to use such callback to define other cargo than mail or passengers, to produce? For example food produced by outskirts houses?
Similar question: is it possible, for multi-tile house, using cargo_type_accept callback, to accept more than 3 types of cargo per whole house?
Yes to both. However, because the callback decision is only available for existing houses it has several drawbacks to the user interface. For example the cargo chain overview will never show houses as accepting or producing something else.
It is probably fine, as long as you do not add new cargos which are only accepted by houses, with no industry accepting them.
Adding a new cargo, which is only accepted by houses, and not by industries, will however break most GameScripts, AIs, and players :)
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
abregado
Engineer
Engineer
Posts: 35
Joined: 02 Apr 2015 22:39

Re: NML - a Newgrf Meta Language

Post by abregado »

Righto, I got a step further. Now I get an arrow regarding my .nml file

Code: Select all

nmlc: "input", line 11: Real sprite paramater 'ysize' out of range 1..255, encountered 256
I checked out some other nmls and they also had sprites over 255 pixels. :(

Code: Select all

// Replace Grass Tiles
replace grass_tiles(3981, "src/topo/gfx/terrainmasksheet.png") {
    [0,0, 256,256, -124,  -66]
    [ 256,0, 256,256, -124,-66]
    [ 256*2,0, 256,256, -124,-66]
    [ 256*3,0, 256,256, -124,-66]
    [ 256*4,0, 256,256, -124,-66]
    [ 256*5,0, 256,256, -124,-66]
    [ 256*6,0, 256,256, -124,-66]
    [ 256*7,0, 256,256, -124,-66]
    [ 256*8,0, 256,256, -124,-66]
    [ 256*9,0, 256,256, -124,-66]
    [ 256*10,0, 256,256, -124,-66]
    [ 256*11,0, 256,256, -124,-66]
    [ 256*12,0, 256,256, -124,-66]
    [ 256*13,0, 256,256, -124,-66]
    [ 256*14,0, 256,256, -124,-66]
    [ 256*15,0, 256,256, -124,-66]
    [ 256*16,0, 256,256, -124,-66]
    [ 256*17,0, 256,256, -124,-66]
}
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: NML - a Newgrf Meta Language

Post by PikkaBird »

NFO version 7 can only encode y-sizes up to 255, vs 65535 for NFO version 32. Presumably there is some similar mechanism at play here...
abregado
Engineer
Engineer
Posts: 35
Joined: 02 Apr 2015 22:39

Re: NML - a Newgrf Meta Language

Post by abregado »

I changed them all to 255 and then it started complaining that ZOOM_LEVEL_IN_4X is not a valid identifier for alpternative_sprites. I guess I have an older version or something :(
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 10 guests