Various NML related questions

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

Moderator: Graphics Moderators

User avatar
Quast65
Tycoon
Tycoon
Posts: 2205
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: Various NML related questions

Post by Quast65 »

Hi all!

I am trying to use a random switch to recolor one of the views of an object.

Code is like this:

Code: Select all

random_switch (FEAT_OBJECTS, SELF, RandomColour_01) {
	1: return COLOUR_BLUE;
	2: return COLOUR_RED;
}
But it only recolors to blue... Red never happens, even though (if I understand it correctly) the chance of it should be double that of blue.

Can anyone help? ?(
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.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5562
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Various NML related questions

Post by andythenorth »

Quast65 wrote: 16 Aug 2022 18:03 I am trying to use a random switch to recolor one of the views of an object.
To isolate the issue...does the recolour to red work otherwise (in a test case without a random switch)?
User avatar
Quast65
Tycoon
Tycoon
Posts: 2205
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: Various NML related questions

Post by Quast65 »

andythenorth wrote: 16 Aug 2022 19:56
Quast65 wrote: 16 Aug 2022 18:03 I am trying to use a random switch to recolor one of the views of an object.
To isolate the issue...does the recolour to red work otherwise (in a test case without a random switch)?
It will recolor to any color I put first, but to none of the colors I place later on.

Its part of a more elaborate recoloring-code, this is the switch I also use:

Code: Select all

switch (FEAT_OBJECTS, SELF, RandomColour_2x1_Random01, view) {
	0: RandomColour_01;
	1: return COLOUR_ORANGE;
}

What it does is:
View-1, That recolors to the color I put first in the random-switch
View-2, That recolors to Orange (later on I also want to use a random-switch for that too)
View3&4, Recolors to the CC and 2CC, set by the player in that game

The thing I am not sure of, is if it is possible at all to randomly recolor objects...
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.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5562
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Various NML related questions

Post by andythenorth »

Quast65 wrote: 16 Aug 2022 20:32 The thing I am not sure of, is if it is possible at all to randomly recolor objects...
I asked on OpenTTD Discord...
[21:53] JGR: The recolour callback is called before the object is placed on the map, so there are no random bits yet...
[21:56] frosch: https://github.com/OpenTTD/OpenTTD/comm ... 77b1c7120d <- there was a similar thing for industries and houses
[21:56] frosch: looks like the same problem was added for objects 🙂
User avatar
Quast65
Tycoon
Tycoon
Posts: 2205
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: Various NML related questions

Post by Quast65 »

andythenorth wrote: 16 Aug 2022 21:01 I asked on OpenTTD Discord...
Thnx for asking!
So, If I understand correctly, its not possible at the moment, but maybe in the future?
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.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5562
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Various NML related questions

Post by andythenorth »

Quast65 wrote: 16 Aug 2022 21:25 So, If I understand correctly, its not possible at the moment, but maybe in the future?
Yes not possible currently, could be possible in future - it would need a change for objects, similar to the change that was made for houses. :wink:
User avatar
Quast65
Tycoon
Tycoon
Posts: 2205
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: Various NML related questions

Post by Quast65 »

andythenorth wrote: 17 Aug 2022 09:08 Yes not possible currently, could be possible in future - it would need a change for objects, similar to the change that was made for houses. :wink:
Righto! Thanks Andy for clearing that up!
Hope it gets implimented, as it is a very handy 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.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 0 guests