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 »

How to define industry as ship/heli station? I defined following flags:

Code: Select all

spec_flags: bitmask(IND_FLAG_BUILT_ON_WATER, IND_FLAG_AI_CREATES_AIR_AND_SHIP_ROUTES);
, its tiles has land_shape_flags: bitmask(LSF_ALLOW_ON_WATER); but it is still normal industry without any station sign.
Should I define any extra tiles? What are these 255 and 24 Id tiles for (as seen at firs source)? Added some but see no difference.
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.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

"255" is the same as "clear". It checks for empty tiles during construction, but does not block anything after construction.

To make the industry build a station:
  • Put exactly two tiles "24" into the layout, which are neighboured in Y direction. That is, if the first tile is at (x, y), the second one must be at (x, y+1).
  • These tiles will look like plain water in-game. Usually they are in the back of the industry and hidden by stuff on tiles in front of them.
  • The first tile will become the station tile, which has the station sign. It also opens the station window instead of the industry window when clicked.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

Thanks for explanation. I was so close to discover this hidden feature (but used only one 24 Id tile)...
If I understand correctly, second 24 tile is a dock for ships and helicopters, and this oil rig helipad is just graphical cover?
Is it described elsewhere?
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

There is no reason why there is a second tile.
It's just how it is for the default oilrig, and it has to be the same.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

I found strange 'floating bug' during nml compilation.
For each compilation, there is 'Expected a compile-time integer constant', but it appears randomly for different places of nml code.
Here is precompiled nml file:
http://149.156.194.203/~mczapkie/Train/ ... olroad.nml
and other files needed to compile it: https://hg.openttdcoop.org/polroad/archive/tip.zip
(or just hg clone http://hg.openttdcoop.org/polroad)

This error is probably related to {string} and {unsigned} position in string (I was changing it lately), but I don't see reason of this bug and don't understand, why compilation error is non-deterministic.

EDIT: nmlc --version

Code: Select all

0.4.0.r5530:84d58305a9ed from 2015-02-21
Library versions encountered:
PLY: 3.4
PIL: 1.1.7
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.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

Some steps during NML compilation do not have a fixed order which they are carried out, so if there are multiple errors in the source, the first error that is found may vary.

If you want to force a deterministic compilation, set the environment variable "PYTHONHASHSEED" to zero. With linux you do that this way:

Code: Select all

env PYTHONHASHSEED=0 make
About the errors in your source. I took a look at the lines, which were reported.
I believe the problem is, that you are missing some "return" statements.

For example the FREIGHT_STTN macro does not use "return" in "switch_##STTN_Name##_running_cost":

Code: Select all

-       PASS: min(STAFF_RUNNING_COST + max(0,((v_mass) * ((e_displacement / 10) + (v_vmax) * (v_vmax)) * v_fuelsystem) >> 15), 255); \
+       PASS: return min(STAFF_RUNNING_COST + max(0,((v_mass) * ((e_displacement / 10) + (v_vmax) * (v_vmax)) * v_fuelsystem) >> 15), 255); \
I fixed some of those cases locally, but I found some cases which are not fixable:

Code: Select all

	0 : (visual_effect_flag == VISUAL_EFFECT_DIESEL) ? switch_high_diesel_smoke_effect : \
	((visual_effect_flag == VISUAL_EFFECT_DIESEL_LOW) ? switch_low_diesel_smoke_effect : CB_FAILED);  \
Here you use the ? : operator to chain to different switches or to return a value. I don't think the ? : operator works for chaining to switches, and it does definitely not work when mixing return values with chaining to other switches.
You will have to replace the ? : operator with an intermediate switch.

Generally you should try to reduce the usage of ? : . It cannot be compiled effectively, better use more switches.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

Strange, that above mentioned issues does not appear during compilation up to 78228defeeb7 revision - all these codes were not touched for a relatively long time, however some kind of suspicious messages appear, not sure if 'concurrent' warns about something wrong?

Code: Select all

 nmlc info: 5831 sprites, 0 cached, 0 orphaned, 43 duplicates, 5788 newly encoded (native)
 nmlc info: Road Vehicle items: 78/65448
 nmlc info: Concurrent Action10 labels: 1/240 ("src/gfx/truck/pragav3s.pnml", line 60)
 nmlc info: Concurrent spritesets: 9/255 ("src/../src/gfx/truck/trailers3m.pnml", line 77)
 nmlc info: Concurrent spritegroups: 37/256 ("src/defSTTM.pnml", line 225)
 nmlc info: Concurrent Action2 registers: 11/127 ("src/defSTTS.pnml", line 77)
 nmlc info: Concurrent ActionD registers: 25/64 ("src/palettes.pnml", line 240)
Maybe your version of nmlc is better and pointed bugs, which were cumulative unnoticed by my version and finally messed everything up?
frosch wrote: I believe the problem is, that you are missing some "return" statements.
Honestly, I don't know, what is exactly difference between return <expression>; and <expression>;
especially if it is used for numbers vs other switches calls,
and what is difference of return statement used or not used for enumerated switch or just directly in graphic section?
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

McZapkie wrote:not sure if 'concurrent' warns about something wrong?

Code: Select all

 nmlc info: 5831 sprites, 0 cached, 0 orphaned, 43 duplicates, 5788 newly encoded (native)
 nmlc info: Road Vehicle items: 78/65448
 nmlc info: Concurrent Action10 labels: 1/240 ("src/gfx/truck/pragav3s.pnml", line 60)
 nmlc info: Concurrent spritesets: 9/255 ("src/../src/gfx/truck/trailers3m.pnml", line 77)
 nmlc info: Concurrent spritegroups: 37/256 ("src/defSTTM.pnml", line 225)
 nmlc info: Concurrent Action2 registers: 11/127 ("src/defSTTS.pnml", line 77)
 nmlc info: Concurrent ActionD registers: 25/64 ("src/palettes.pnml", line 240)
those are not warnings. it's purely informational, to show you whether you are close to some internal limits.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

I checked various revisions. It looks like your changes in 163:508f369dc899 introduce the issue.

However, you do not seem to change anything wrt. the error location, so I believe the error location is completely bogus.

Anyway, your code is too complicated for me to follow. Please experiment a bit yourself with your change in 163:508f369dc899 and see whether you can work out some pattern.

BTW: You should remove the .nml file from the repository. It is a generated file. It being present may result in build failure (but it is not the issue here).
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

frosch wrote:I checked various revisions. It looks like your changes in 163:508f369dc899 introduce the issue.
Right. I just swapped strings and numerical values nested in string call, and it messed everything up (expected compiled constant value - but both string call and english.txt string/unsigned word placements were correct).
Probably compiler cannot handle properly ?: operators used to choose string, I will make additional switch as was suggested.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Can I ask a question?

I making the NSWTrains and AuzTrains sets and using codes from 2cc Trains in NML.

The DMU & EMUs .. they have their middlepass and middlemail carriages.

Is there away so that the Middlemail can go on the end?

DMUs and EMUs here in Australia have a Mail Van as the last vehicle, attached to the rear.

If can be done can I trouble someone for the code to change or some ideas how?

Thanks kindly.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Hi all,

I been using the 2cc TrainsInNML to design my own NSWTrains and AuzTrains.

Having a practice to see if I can add wagons longer then Length 8, but it will not accept.

I have all the sprit sizes right, just they over lap when set on Length: 8; and if try change it to a larger size I get this message "vehicle length out of range 1..8, encountered 10".

Can some one give me a hint how to make it accept vehicles longer than 8?.

Thanks fellas
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

Secretly those vehicles consist of two articulated parts. One part with length 8 and one with length 2. Check the source for the Big Boy (graphics-file and item-file).

Ignore the comment that says that it is build as a 3+4+3 parts, that is how it was done earlier in the set, but was changed to make it work easier for players in the depot window as only the first part could be selected/moved. (Also, I should update that comment).

I use the articulated_part switch to add parts when it is bought, and some other switches to set the properties correct for each part (visual effects, length, and which sprite to show).
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Secretly those vehicles consist of two articulated parts
Thanks for helping Transportman .. I presume need to make 2 drawings of the vehicle .. 1 a length of up to 8 and the other the remaining length?
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: NML - a Newgrf Meta Language

Post by TadeuszD »

GarryG wrote:I presume need to make 2 drawings of the vehicle .. 1 a length of up to 8 and the other the remaining length?
It depends. ;)
For vehicles with length up to 10 you can create only one bigger drawing for first vehicle only. The second vehicle should be invisible.
For vehicles longer than 10 you should create (complicated) algorithms for displaying sprites for first and second vehicle separately to prevent glitches with tunnels, bridges, curves, etc...
Please look at http://dev.openttdcoop.org/projects/pkp ... /bhxz.pnml, to find some tricks.
Image
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Thank you kindly for help TadeuszD. What you and Transportman have told me .. going to be interesting trying these ideas and see what I can do.

Thanks for offering your help.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

TadeuszD wrote:
GarryG wrote:I presume need to make 2 drawings of the vehicle .. 1 a length of up to 8 and the other the remaining length?
It depends. ;)
For vehicles with length up to 10 you can create only one bigger drawing for first vehicle only. The second vehicle should be invisible.
For vehicles longer than 10 you should create (complicated) algorithms for displaying sprites for first and second vehicle separately to prevent glitches with tunnels, bridges, curves, etc...
Please look at http://dev.openttdcoop.org/projects/pkp ... /bhxz.pnml, to find some tricks.
The 2cc TrainsInNML goes up to length 12 as single sprites. But it really is a matter of what you think looks nice and what you find acceptable.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Can some one help me code the Signal Box in this file. Want it to sit on natural ground and not one of the four tiles it came with.

I got the information from Friss-stations, but I don't need the four ground tiles.

I tried to find and understand how to do it, but never got anywhere. If someone be kind enough to change what is needed in these files for me and either PM it to me or upload back here be very much appreciated.

Thank you kindly.
Attachments
AuzLinesideObjects.rar
(264.58 KiB) Downloaded 59 times
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

Assuming you mean the signal-boxes in the objects folders that are in the src and gfx folders, wouldn't you be done with changing the ground tiles in the gfx to transparent blue?
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

I tried to change all the tiles to transparent blue .. but when tested the graphics played up. Extra parts of the building appeared in the tile area.

Don't need to do all the building for me .. just the one I have in the NML file .. as I can learn what you did to do the others.

Update:

Here's a pic of what I mean.
Attachments
Graphics problem.png
Graphics problem.png (310.24 KiB) Viewed 2357 times
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 18 guests