Various NML related questions
Moderator: Graphics Moderators
Re: Various NML related questions
i don't think that info is exposed to NewGRFs, at least i didn't find it
Re: Various NML related questions
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?
- andythenorth
- Tycoon
- Posts: 5658
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Various NML related questions
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.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: Various NML related questions
Thank you for your input, really appreciated!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
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").
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.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.
Re: Various NML related questions
In regard to "incoming_cargo_waiting("WOOD") (for example), is it possible for NML to access this value for changing the value?
I can manipulate a reduction by using PRODUCE but I also wish to add to this value (not for the purposes of cheating) but to be able to manipulate stockpile quantities.
I have some code that can do it at the moment but it's not very good. If I could gain access to the actual variable/register then I could do something quite useful (I'm hoping...) but I'm guessing that NML can't access this.
I can manipulate a reduction by using PRODUCE but I also wish to add to this value (not for the purposes of cheating) but to be able to manipulate stockpile quantities.
I have some code that can do it at the moment but it's not very good. If I could gain access to the actual variable/register then I could do something quite useful (I'm hoping...) but I'm guessing that NML can't access this.
- andythenorth
- Tycoon
- Posts: 5658
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Various NML related questions
What happens if you return negative values from PRODUCE? (genuine question)
There's no other direct manipulation. In a nutshell, properties/vars are modified by callbacks, PRODUCE is the callback for modifying stockpile.
Alternatively you can maintain a shadow implementation of stockpiles using industry permanent storage, but you can't then use the industry window text default handling for display of stockpile amounts. You could probably write your own though.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: Various NML related questions
I was about to write that no you can't subtract negative consumption of input cargo, but it looks like you're supposed to be able to, actually.
The comment here newgrf_spritegroup.h:273 says "Take this much of the input cargo (can be negative)", so try it out.
The comment here newgrf_spritegroup.h:273 says "Take this much of the input cargo (can be negative)", so try it out.
Re: Various NML related questions
I did think of that (adding a negative value), and it doesn't work. I'd guess there's a check somewhere that treats -ve values as 0. So, no it doesn't work.
I currently DO use industry internal registers as a virtual storage but it's messy so I've disabled it for now (and it has an oversight on my part so it doesn't work perfectly yet). I could display this value but I already use all the available registers TEMP( 256-261) for displaying other stuff.
I'd like a few more printable variables, but I'm unlikely to get those either...but if negative produce values did actually work then I could use 256-261 for displaying storage quantities for what I have in mind.
I currently DO use industry internal registers as a virtual storage but it's messy so I've disabled it for now (and it has an oversight on my part so it doesn't work perfectly yet). I could display this value but I already use all the available registers TEMP( 256-261) for displaying other stuff.
I'd like a few more printable variables, but I'm unlikely to get those either...but if negative produce values did actually work then I could use 256-261 for displaying storage quantities for what I have in mind.
Re: Various NML related questions
I am writing a town_name.grf.
It encounters a compile error at about 700 lines of text, removing some lines fixes it.
Is it a invisible cap limit?
It encounters a compile error at about 700 lines of text, removing some lines fixes it.
Is it a invisible cap limit?
Code: Select all
Not enough random bits for the town name generation (34 needed, 32 available)
Re: Various NML related questions
You have (as the message says) 32 random bits available. each independent random decision uses up one or more of these. you can try reorganizing your code that some random decisions share the same bits (they won't be independent anymore)
Re: Various NML related questions
Hi all,
I have noticed that in several house-sets some sort of recolour is used, so that one single graphic has different appearences ingame.
For example an awning of a shop can have different colors.
I believe it is somehow done by (possibly random) recoloring of the blue Company Colors of the palette.
Can this also be done for objects?
And, if so, how?
As I have not yet found the sources of a NML-coded house-set that has this feature.
I have noticed that in several house-sets some sort of recolour is used, so that one single graphic has different appearences ingame.
For example an awning of a shop can have different colors.
I believe it is somehow done by (possibly random) recoloring of the blue Company Colors of the palette.
Can this also be done for objects?
And, if so, how?
As I have not yet found the sources of a NML-coded house-set that has this feature.
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.
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.
Re: Various NML related questions
Good to know!
Do you possibly know of any GRF's that use this feature (doesnt have to be objects), that have sources for me to look at?
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.
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.
- 2TallTyler
- Route Supervisor
- Posts: 507
- Joined: 11 Aug 2019 18:15
- Contact:
Re: Various NML related questions
Improved Town Layouts uses random recolouring for sub-arctic houses. It needs a few different pieces to work:
1. The spritelayout needs to specify that the sprite can be recoloured. ITL uses baseset sprites which are referred to by number, but the code is the same for new sprites which use a spriteset.
2. The house needs the `colour` callback.
3. A random colour is chosen by a random switch. (A regular switch also works if you want to choose colours based on your own logic — I do this with my land value algorithm for sub-tropic houses.)
1. The spritelayout needs to specify that the sprite can be recoloured. ITL uses baseset sprites which are referred to by number, but the code is the same for new sprites which use a spriteset.
Code: Select all
spritelayout sprite_arctic_48_house {
ground { sprite: terrain_type == TILETYPE_SNOW ? 4429 : 4428; }
building {
sprite: (construction_state == 0 ? 4430 : (construction_state == 3 ? (terrain_type == TILETYPE_SNOW ? 4433 : 4432) : 4431));
recolour_mode: RECOLOUR_REMAP;
palette: PALETTE_USE_DEFAULT;
}
}
Code: Select all
graphics {
default: sprite_arctic_48_house;
construction_check: switch_arctic_house_a;
colour: RandomColourArcticHouses();
}
Code: Select all
random_switch (FEAT_HOUSES, SELF, RandomColourArcticHouses) {
1: return PALETTE_CC_DARK_BLUE;
1: return PALETTE_CC_PALE_GREEN;
1: return PALETTE_CC_PINK;
1: return PALETTE_CC_LIGHT_BLUE;
1: return PALETTE_CC_DARK_GREEN;
1: return PALETTE_CC_CREAM;
1: return PALETTE_CC_MAUVE;
1: return PALETTE_CC_ORANGE;
1: return PALETTE_CC_BROWN;
}
Re: Various NML related questions
Thank you for your reply!
If I use the above code, with changing
to
offcourse,
I get an error message like this: the number (0x308 in this case) corresponds with the first color in the list (in this case I put PALETTE_CC_PALE_GREEN on top).
Also no recoloring (at least none to the color at the top of the list) and certainly no random recoloring when placing the object more times.
But, if I change the color list to for example this:
I dont get an error message anymore, but the recoloring is only to the first color of the list...
Sadly that doesnt do the trick for Objects...
If I use the above code, with changing
Code: Select all
FEAT_HOUSES
Code: Select all
FEAT_OBJECTS
I get an error message like this: the number (0x308 in this case) corresponds with the first color in the list (in this case I put PALETTE_CC_PALE_GREEN on top).
Also no recoloring (at least none to the color at the top of the list) and certainly no random recoloring when placing the object more times.
But, if I change the color list to for example this:
Code: Select all
random_switch (FEAT_OBJECTS, SELF, RandomColour_2x1_Random01) {
1: return COLOUR_YELLOW;
1: return COLOUR_RED;
1: return COLOUR_GREEN;
1: return COLOUR_BLUE;
}
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.
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.
Re: Various NML related questions
Hello
I have a few questions.
1. When replacing base set sprites the NML-specification for replace speaks about a "list of real sprites" and shows an example with a few sprite definitions. Is it also possible to replace a base graphic sprite with only the ID of another base set sprite? Purpose: I want to replace the sidewalk sprites with the grass-only sprite from the matching landscape type from the base set used in the game without knowing the positions and dimensions of the sprites.
2. I studied the code of many NRT sets and came across definitions like the following (actually taken from docklands but present in many sets).
Beside the fact, that this code is resampled in many sets and the in many sets not matching pixel positions provided to the function ground_tile, the question for me is, what purpose have the definitions after the comments " /* X-crossing */" and "/* underlay for crossings w/o tracks */"? "X-crossing" could imho only mean the crossroad because this is the only sprite without a mirrored or turned counterpart. But the crossroad sprite is already defined in the template tmpl_underlay_junctions together with the four branches.
Also the definitions after the comment "underlay for crossings w/o tracks" makes no sense to me. I assumed these are the sprites for rail crossings or tunnel entrances and exits but a test with plain coloured sprites did not make anything. The rail crossing as well as the tunnel sprites was displayed with the "normal" straight road sprites and not with the coloured. Does these definitions do anything or are they made at a time when the feature set of NRT was not finalised and try to do anything, NRT isn't able to?
Tschö, Auge
I have a few questions.
1. When replacing base set sprites the NML-specification for replace speaks about a "list of real sprites" and shows an example with a few sprite definitions. Is it also possible to replace a base graphic sprite with only the ID of another base set sprite? Purpose: I want to replace the sidewalk sprites with the grass-only sprite from the matching landscape type from the base set used in the game without knowing the positions and dimensions of the sprites.
2. I studied the code of many NRT sets and came across definitions like the following (actually taken from docklands but present in many sets).
Code: Select all
template tmpl_underlay_roadtypes() {
tmpl_underlay_straight()
tmpl_underlay_junctions()
tmpl_underlay_corners()
tmpl_underlay_slope()
tmpl_underlay_half_tiles()
/* X-crossing */
ground_tile(0, 120)
/* underlay for crossings w/o tracks */
ground_tile( 0, 130)
ground_tile(225, 130)
ground_tile(150, 130)
ground_tile( 75, 130)
}
Also the definitions after the comment "underlay for crossings w/o tracks" makes no sense to me. I assumed these are the sprites for rail crossings or tunnel entrances and exits but a test with plain coloured sprites did not make anything. The rail crossing as well as the tunnel sprites was displayed with the "normal" straight road sprites and not with the coloured. Does these definitions do anything or are they made at a time when the feature set of NRT was not finalised and try to do anything, NRT isn't able to?
Tschö, Auge
Re: Various NML related questions
the rail crossing underlays are only visible if you use a railtype with enabled crossing overlay, otherwise the combined crossing sprite from the railtype is used, which will completely cover the underlay sprite
Re: Various NML related questions
Hello
quote=Eddi post_id=1252118 time=1646092992 user_id=15964]
the rail crossing underlays are only visible if you use a railtype with enabled crossing overlay, otherwise the combined crossing sprite from the railtype is used, which will completely cover the underlay sprite
[/quote]
Are you sure? In the following screenshot the right rail track is the default ingame track without a crossing overlay. It uses the normal rail and the level crossing lights. The left one is the abandoned rail type from useless-tracks-GRF which provides an overlay. Both level crossings does display the normal straight road. After your reply I expected the level crossing of the abandoned track (the one with the overlay) to display one of the unicoloured sprites I mentioned in my previous posting.
My problem with this is my poor understandig of it because the NML-specs for roadtypes does not mention any of the sprite definitions in question, that I see in so many sets. So I'm kind of lost here.
Thank you nevertheless, tschö, Auge
quote=Eddi post_id=1252118 time=1646092992 user_id=15964]
the rail crossing underlays are only visible if you use a railtype with enabled crossing overlay, otherwise the combined crossing sprite from the railtype is used, which will completely cover the underlay sprite
[/quote]
Are you sure? In the following screenshot the right rail track is the default ingame track without a crossing overlay. It uses the normal rail and the level crossing lights. The left one is the abandoned rail type from useless-tracks-GRF which provides an overlay. Both level crossings does display the normal straight road. After your reply I expected the level crossing of the abandoned track (the one with the overlay) to display one of the unicoloured sprites I mentioned in my previous posting.
My problem with this is my poor understandig of it because the NML-specs for roadtypes does not mention any of the sprite definitions in question, that I see in so many sets. So I'm kind of lost here.
Thank you nevertheless, tschö, Auge
- colossal404
- Chief Executive
- Posts: 652
- Joined: 07 Mar 2009 12:48
- Location: Szeged, Hungary
Re: Various NML related questions
Hai guise!
I'd like to ask about sprite stacking, is it currently limited to max 4 layers / articulated part by nml, or by OTTD itself? I would like to use more of it, so I could spare time on making sprites (and waste time to write the code to a grf I will never finish )
I'd like to ask about sprite stacking, is it currently limited to max 4 layers / articulated part by nml, or by OTTD itself? I would like to use more of it, so I could spare time on making sprites (and waste time to write the code to a grf I will never finish )
Re: Various NML related questions
Yes, four is the maximum in OpenTTD, regardless of how the NewGRF is coded.
Who is online
Users browsing this forum: No registered users and 20 guests