Various NML related questions

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

Moderator: Graphics Moderators

User avatar
3iff
Tycoon
Tycoon
Posts: 1012
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Various NML related questions

Post by 3iff »

Yes, that's what I found (and suspected). Setting production to 0 per cycle generates 180-225t/month (45t per treecut instance). If I set production to 10 per cycle (256 ticks) I get 800t per month!

I would support some change. I might like a flag that cut trees but didn't produce anything - that could be handled by 'normal' production settings every 256 ticks. That would make the tree cutting a cosmetic effect and the lumber mill (or whatever industry is the source) be able to produce cargo regardless of whether there are local trees to cut or not.

That essentially is what I was aiming for but it was just an experiment that currently doesn't work. I didn't realise it was a can of worms.

If there are any changes in this area I'd appreciate being kept up to date...and I'm happy to beta test anything should that be needed.
Alon
Engineer
Engineer
Posts: 30
Joined: 22 Jul 2019 14:07

Re: Various NML related questions

Post by Alon »

Hi,
I'm trying to create a rail track with smooth curves using nml. What I'm trying to achieve is automatically changing the sprite of connected rail depending in the change of direction eg. Track NE connected to track N, they both change their sprite to create a smooth edges of tracks.


Is it possible a railpiece can detect the type of the other railpiece connected to them?(maybe an example will help)


If someone already created a smooth trackset it can be more helpful to see their source.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Various NML related questions

Post by planetmaker »

Alon wrote: 22 May 2020 03:27 Is it possible a railpiece can detect the type of the other railpiece connected to them?(maybe an example will help)
No, that's currently not possible. You cannot read the tracks directions of adjacent tiles. IIRC, one of the main reasons is the performance impact this might have on the game - but my memory might be fuzzy there.

That said, a solution similar to how canals/rivers are handled can be envisioned in form of some patch series / pull requests to OpenTTD's source code. But that would need to go through much scrutiny as tracks are much more abundant and there's more track types than water types as the latter cannot be user-defined)
User avatar
jfs
Tycoon
Tycoon
Posts: 1250
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Various NML related questions

Post by jfs »

Curved track would also need to affect where trains running on it are drawn, and players would probably begin requesting more rotation sprites for the trains too.
Alon
Engineer
Engineer
Posts: 30
Joined: 22 Jul 2019 14:07

Re: Various NML related questions

Post by Alon »

jfs wrote: 22 May 2020 17:36 Curved track would also need to affect where trains running on it are drawn, and players would probably begin requesting more rotation sprites for the trains too.
That is not a problem, extra rotation sprites are now used in some Trainset grfs like CETS(which is unavailable) and Polish PKP set 2.0(partially supports additional rotation sprites). For normal trainsets a parameter or checks should be made to disable the curved tracks.


That's why I came up an idea to create a trackset with smooth curves, for Trainset that support extra rotation sprites.


Conclusion: if that's really possible someone should have done the similar idea before. Maybe in future this can be implemented.
User avatar
TrainLover
Engineer
Engineer
Posts: 108
Joined: 01 Jul 2015 15:03

Re: Various NML related questions

Post by TrainLover »

I was finally able to figure out how to setup a MakeFile, but whenever I use it, I keep getting an unexpected token in header.pnml. Do you know what is happening and how I could fix it?
Developer of North American Passenger Liveries: viewtopic.php?f=26&t=87228
User avatar
jfs
Tycoon
Tycoon
Posts: 1250
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Various NML related questions

Post by jfs »

Remember "pnml" is a Python script, not an NML file, you need to have it run with the correct version of Python.
User avatar
2TallTyler
Traffic Manager
Traffic Manager
Posts: 203
Joined: 11 Aug 2019 18:15
Contact:

Re: Various NML related questions

Post by 2TallTyler »

jfs wrote: 17 Jun 2020 16:33 Remember "pnml" is a Python script, not an NML file, you need to have it run with the correct version of Python.
Is it? I've always seen them used to hold a portion of the NML code, which is combined by a Python script (.py extension) into one long NML file, then that merged file is processed with NMLC into the .grf. The file extension is somewhat arbitrary, possibly meaning "pre-nml" or "partial-nml".

This is how my projects are set up, although I use .nml rather than .pnml as my arbitrary file extension. My makefile is a Windows Batch file (.bat) which simply runs the Python script, then NMLC, then moves the completed file to my OpenTTD NewGRF directory. For reference, here is a project repository with explanatory comments in the admittedly-flawed makefile.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9415
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Various NML related questions

Post by planetmaker »

jfs wrote: 17 Jun 2020 16:33 Remember "pnml" is a Python script, not an NML file, you need to have it run with the correct version of Python.
For all projects I meddled with that's not correct (and that's probably the majority where you find files with that extention). In those cases it's an nml file which still needs pre-processing; thus it needs running it through the cpp pre-processor in order to handle some macros expansion and including further source files.
User avatar
Tintinfan
Engineer
Engineer
Posts: 79
Joined: 29 Sep 2010 11:36

Re: Various NML related questions

Post by Tintinfan »

Hello,

I've been trying to access "num_vehs_in_vehid_chain" through "var[0x61, 0, 0x00FF0000, 0x41]" - but I'm always getting a CB_FAILED/default response (nothing in the range 1-256). I have been able to use "var[0x61, 0, 0x000000FF, 0x41]" to obtain the "position_in_vehid_chain" - and figured moving the "FF" over to the position as shown in the nfo format and debug panel would work just as well but I get nothing.

Is my formatting here wrong or am I trying to access something that I shouldn't be? I have tried it both ways round as well - running 0x000000FF before 0x00FF0000...but 0x00FF0000 is not happy. :(

Code Snippets:
[+] Spoiler

Code: Select all

switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantograph_numofcars, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x00FF0000, 0x41]]){ //look at opposite num_vehs_in_vehid_chain
  1..5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  6..256: sw_E233_gfx_rev_flippedcheck_pantogaph_dual;
  CB_FAILED; //always fails here
}
switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantograph_pos, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x000000FF, 0x41]%8]){ //look at opposite position_in_vehid_chain
  1: sw_E233_gfx_rev_pantograph_numofcars;
  5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  7: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  default: sw_E233_gfx_rev_flippedcheck_mucar;
}

Code: Select all

switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantogroup_B, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x000000FF, 0x41]]){ //look at opposite position_in_vehid_chain
  1: sw_E233_gfx_rev_flippedcheck_pantogaph_dual;
  5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  7: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  default: sw_E233_gfx_rev_flippedcheck_mucar;
}
switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantogroup_A, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x000000FF, 0x41]]){ //look at opposite position_in_vehid_chain
  1: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  7: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  default: sw_E233_gfx_rev_flippedcheck_mucar;
}
switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantograph_pos, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x00FF0000, 0x41]]){ //look at opposite num_vehs_in_vehid_chain
  0..5: sw_E233_gfx_rev_pantogroup_A;
  6..256: sw_E233_gfx_rev_pantogroup_B;
  CB_FAILED; //always fails here
}
Regards,

Tinny/Tintinfan. :)
User avatar
Tintinfan
Engineer
Engineer
Posts: 79
Joined: 29 Sep 2010 11:36

Re: Various NML related questions

Post by Tintinfan »

Tintinfan wrote: 20 Jun 2020 09:40 Hello,

I've been trying to access "num_vehs_in_vehid_chain" through "var[0x61, 0, 0x00FF0000, 0x41]" - but I'm always getting a CB_FAILED/default response (nothing in the range 1-256). I have been able to use "var[0x61, 0, 0x000000FF, 0x41]" to obtain the "position_in_vehid_chain" - and figured moving the "FF" over to the position as shown in the nfo format and debug panel would work just as well but I get nothing.

Is my formatting here wrong or am I trying to access something that I shouldn't be? I have tried it both ways round as well - running 0x000000FF before 0x00FF0000...but 0x00FF0000 is not happy. :(

Code Snippets:
[+] Spoiler

Code: Select all

switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantograph_numofcars, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x00FF0000, 0x41]]){ //look at opposite num_vehs_in_vehid_chain
  1..5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  6..256: sw_E233_gfx_rev_flippedcheck_pantogaph_dual;
  CB_FAILED; //always fails here
}
switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantograph_pos, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x000000FF, 0x41]%8]){ //look at opposite position_in_vehid_chain
  1: sw_E233_gfx_rev_pantograph_numofcars;
  5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  7: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  default: sw_E233_gfx_rev_flippedcheck_mucar;
}

Code: Select all

switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantogroup_B, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x000000FF, 0x41]]){ //look at opposite position_in_vehid_chain
  1: sw_E233_gfx_rev_flippedcheck_pantogaph_dual;
  5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  7: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  default: sw_E233_gfx_rev_flippedcheck_mucar;
}
switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantogroup_A, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x000000FF, 0x41]]){ //look at opposite position_in_vehid_chain
  1: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  5: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  7: sw_E233_gfx_rev_flippedcheck_pantograph_single;
  default: sw_E233_gfx_rev_flippedcheck_mucar;
}
switch(FEAT_TRAINS, SELF, sw_E233_gfx_rev_pantograph_pos, [STORE_TEMP(position_in_consist_from_end-position_in_consist, 0x10F), var[0x61, 0, 0x00FF0000, 0x41]]){ //look at opposite num_vehs_in_vehid_chain
  0..5: sw_E233_gfx_rev_pantogroup_A;
  6..256: sw_E233_gfx_rev_pantogroup_B;
  CB_FAILED; //always fails here
}
Well, it looks like after a little bit more digging that "var[0x61, 16, 0x000000FF, 0x41]" does the trick - or at least seems to do the trick, not sure if luck or logic but this document helped.
Regards,

Tinny/Tintinfan. :)
Eddi
Tycoon
Tycoon
Posts: 7530
Joined: 17 Jan 2007 00:14

Re: Various NML related questions

Post by Eddi »

Tintinfan wrote: 21 Jun 2020 07:16 Hello,

I've been trying to access "num_vehs_in_vehid_chain" through "var[0x61, 0, 0x00FF0000, 0x41]" - but I'm always getting a CB_FAILED/default response (nothing in the range 1-256).
[...]
Well, it looks like after a little bit more digging that "var[0x61, 16, 0x000000FF, 0x41]" does the trick
Well, OK then, let's step this through what each of these does, and why one works and the other doesn't.

so you check var 41 (via var 61), which is apparently bitstuffing several BYTE values into one DWORD (i haven't checked which ones, but it doesn't matter), so var 41 will return a number like 0xaabbccdd.

so the var[num, shift, mask, parameter] syntax will first shift the result, and then apply a mask.

in var[0x61, 0, 0x00FF0000, 0x41] the result will be shifted by 0, intermediate result will be 0xaabbccdd
and then apply a mask of 0x00FF0000, so the result will be 0x00bb0000
in var[0x61, 16, 0x000000FF, 0x41] the result will be shifted by 16, intermediate result will be 0x0000aabb
and then apply a mask of 0x000000FF, so the result will be 0x000000bb
You might not exactly be interested in Ferion, but if you are, have fun :)
McZapkie
Tycoon
Tycoon
Posts: 1210
Joined: 18 Jan 2014 18:10

Re: Various NML related questions

Post by McZapkie »

Is it possible to check for tracktype if neighboring tile is station or not? I don't see such variables on nml tracktypes page, not sure if it is even implemented.
I would like to check such condition to change graphic of catenary: individual pole for standalone tracks vs gantry in case of stations larger than 1 track.
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.
madrito
Engineer
Engineer
Posts: 19
Joined: 05 Jul 2018 15:38

Re: Various NML related questions

Post by madrito »

McZapkie wrote: 01 Oct 2020 08:42 Is it possible to check for tracktype if neighboring tile is station or not? I don't see such variables on nml tracktypes page, not sure if it is even implemented.
I would like to check such condition to change graphic of catenary: individual pole for standalone tracks vs gantry in case of stations larger than 1 track.
I don't know if for sure, but
on page : https://drive.google.com/drive/folders/ ... QdUFegEqTr
view files : m4nfo_stations... & CZTR_Stations.nfo
maybe it's implemented there

probably not CZTR_RAILS.nml : https://drive.google.com/drive/folders/ ... FNGV19hMkk
MLG
Engineer
Engineer
Posts: 26
Joined: 07 Sep 2020 15:12

Lights related question

Post by MLG »

Hi all,
I am making a new version of my train grfs, and I have this question: is there something, which could disable animating of animated colours? I would like to not animate lights of my EMU. Now, I have two versions of parts with lights: front part has brightest and darkest colours from cycle of runway lights, while the back part has crossing cycle colours. I would like, to have them not animating, because animating of these makes no sence... I have tried to look at some source codes, but I know about only one set, which I think, has that working, but it does not have public source. (french narrow gauge trains)

All help from you welcomed.
greets MLG
You can write to me in English, or Czech.
Můžete mi psát česky, nebo anglicky.
User avatar
2TallTyler
Traffic Manager
Traffic Manager
Posts: 203
Joined: 11 Aug 2019 18:15
Contact:

Re: Various NML related questions

Post by 2TallTyler »

There is a flag in the sprite block for whether a sprite is animated or not. I don’t know if it actually disables the animation or just changes whether NML gives a warning.

A better option would be to simply change the color to a non-animated color.
User avatar
Quast65
Tycoon
Tycoon
Posts: 1801
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: Lights related question

Post by Quast65 »

2TallTyler wrote: 25 Oct 2020 14:01 There is a flag in the sprite block for whether a sprite is animated or not. I don’t know if it actually disables the animation or just changes whether NML gives a warning.

A better option would be to simply change the color to a non-animated color.
MLG wrote: 25 Oct 2020 11:05
Indeed, use other colors (that are close to the ones that animate).
Or, code in 32bpp colors. They wont animate unless you use a MASK-file with those colors.
The flag 2Talltyler wrote about is (I think) just to disable the NML warning, it does nothing else.
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
MLG
Engineer
Engineer
Posts: 26
Joined: 07 Sep 2020 15:12

Re: Lights related question

Post by MLG »

Quast65 wrote: 25 Oct 2020 18:16 Indeed, use other colors (that are close to the ones that animate).
Or, code in 32bpp colors. They wont animate unless you use a MASK-file with those colors.
Okay, I will change colours to some others.
And doing 32bpp graphics requires some 3d modelling software (blender,...), while I do not have any expierence with them. And, for me, it is not perfect, when you have everything in 8bpp, and huh, a 32bpp train. :)
You can write to me in English, or Czech.
Můžete mi psát česky, nebo anglicky.
User avatar
Erato
Director
Director
Posts: 525
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Lights related question

Post by Erato »

MLG wrote: 26 Oct 2020 08:00 And doing 32bpp graphics requires some 3d modelling software (blender,...), while I do not have any expierence with them. And, for me, it is not perfect, when you have everything in 8bpp, and huh, a 32bpp train. :)
This is actually not true. 32bpp refers to not being limited to a certain palette. See here for a more detailed explanation of 32bpp and extra zoom.
viewtopic.php?f=26&t=83238

If you use 32bpp, then the colour you wanted to use won't be animated, because it won't be associated with that spot on the palette that refers to an animated colour.
Here's a page in the tutorial about how to implement it:
https://www.tt-wiki.net/wiki/NMLTutorial/32_bit_sprites
https://www.tt-wiki.net/wiki/NMLTutoria ... it_sprites
No pics no clicks. Seriously.
ImageImageImageImageImageImageImage
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests