Various NML related questions

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

Moderator: Graphics Moderators

Eddi
Tycoon
Tycoon
Posts: 7764
Joined: 17 Jan 2007 00:14

Re: Various NML related questions

Post by Eddi »

i don't think that info is exposed to NewGRFs, at least i didn't find it
You might not exactly be interested in Ferion, but if you are, have fun :)
Bad_Brett
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 01 Feb 2007 17:59
Location: Stockholm, Sweden

Re: Various NML related questions

Post by Bad_Brett »

Eddi wrote: 31 Aug 2021 23:59 i don't think that info is exposed to NewGRFs, at least i didn't find it
Hm as I suspected then. It would have been a nice variable to have though, especially if the "length" callback is used. I wonder how much work it would take to expose it?
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5414
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Various NML related questions

Post by andythenorth »

Bad_Brett wrote: 01 Sep 2021 05:31 Hm as I suspected then. It would have been a nice variable to have though, especially if the "length" callback is used. I wonder how much work it would take to expose it?
If you're happy to only support trains from your own grf, you could:

* inject the length of each vehicle as a compile time var, via your compile (return the lengths from a procedure, using the vehicle ID as a parameter)
* use var 60 https://newgrf-specs.tt-wiki.net/wiki/V ... e_.2860.29 to count up the number of each vehicle type in the consist
* multiply the number of each vehicle type by the length of that vehicle
* sum the results, and divide by 16

This assumes you have a templated compile, and aren't just writing nml by hand or something.

Or there might be an 80+ var you can use, but they generally come with a health warning. I can't see one in here but eh http://marcin.ttdpatch.net/sv1codec/TTD-locations.html

It's probably not that hard to add it as a var to OpenTTD, but it's very unlikely that will happen, as there is currently nobody who is comfortable reviewing newgrf spec extensions.
Bad_Brett
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 01 Feb 2007 17:59
Location: Stockholm, Sweden

Re: Various NML related questions

Post by Bad_Brett »

andythenorth wrote: 01 Sep 2021 12:20 If you're happy to only support trains from your own grf, you could:

* inject the length of each vehicle as a compile time var, via your compile (return the lengths from a procedure, using the vehicle ID as a parameter)
* use var 60 https://newgrf-specs.tt-wiki.net/wiki/V ... e_.2860.29 to count up the number of each vehicle type in the consist
* multiply the number of each vehicle type by the length of that vehicle
* sum the results, and divide by 16

This assumes you have a templated compile, and aren't just writing nml by hand or something.

Or there might be an 80+ var you can use, but they generally come with a health warning. I can't see one in here but eh http://marcin.ttdpatch.net/sv1codec/TTD-locations.html
Thank you for your input, really appreciated! :)

In my case, if I only support trains from my NewGRF, it's probably even easier since all my engines and cars have been splitted in equal parts. So all I have to do is to multiply the number of parts with the standard part length... But like you said, this won't work together with other NewGRF's. On the other hand, since the vehicle count will be much higher in my NewGRF than in most others, the worst thing that can happen is that the callbacks won't work properly (which means that the game will run "as expected").
It's probably not that hard to add it as a var to OpenTTD, but it's very unlikely that will happen, as there is currently nobody who is comfortable reviewing newgrf spec extensions.
I see...That's a pity. I just want to let you know that I'm completely blown away by the latest additions to nml. It really feels as the game is about to reach it's full potential when it comes to modding capabilities and I'm really thankful for all the work you've put into it. :)
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 5 guests