Random colors on objects

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

Moderator: Graphics Moderators

Post Reply
GojkoG
Engineer
Engineer
Posts: 14
Joined: 06 Dec 2017 18:45

Random colors on objects

Post by GojkoG »

Hi all!
I have a little variation of the New Towns set with a lot of nice random things like colors. That’s easy for Houses (callback 14, randomaction2 and some color values):

On objects I use property 15 (callback flag), value 8 (color)

Code: Select all

   59 * 11	 02 0F \bx02  80  00 00  \b4 \wx8003 \wx8007 \wx8004 \wx8009
   61 * 17	 02 0F \bx01  85 0C  00 \wxFFFF  \b1 \wx02 \wx015B \wx015B  \wx03
   60 * 7	 03 0F 01 \bx00 00 \wx01
Unfortunately all the buildings always have the first color (0x8003) of the random set. I already checked if RandomAction2 is broken for objects, but it works when I take it as switch for two different graphics. What do I do wrong? Is it even possible to have random coloring on objects?

The second question is where I find the list for these colors, because they are different from the ones I used for Houses.
(https://newgrf-specs.tt-wiki.net/wiki/RecolorSprites)
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Random colors on objects

Post by michael blunck »

I don't think it works like this. Instead, callback 15B does the recolouring "automagically", i.e. by simply using the current company number, or doing a random recolouring in case there's no company at all.

For self-defined recolourings, you'd need to additionally specify the TTD or custom recolour tables yourself in the object's action2.

regards
Michael
Image
GojkoG
Engineer
Engineer
Posts: 14
Joined: 06 Dec 2017 18:45

Re: Random colors on objects

Post by GojkoG »

Thanks, Michael, it worked!
I didn’t know that I simply can use the other bits on action’s sprite image ID for recoloring according to https://newgrf-specs.tt-wiki.net/wiki/RecolorSprites.

Code: Select all

   57 * 17	 02 0F \bx03  00  \dx80000000 \dx83078002  \b0 \b0  \b16 \b16 \b25	// dark blue (0x307)
   58 * 17	 02 0F \bx02  00  \dx80000000 \dx83088002  \b0 \b0  \b16 \b16 \b25	// pale green (0x308)
   59 * 11	 02 0F \bx01  80  00 00  \b2 \wx02 \wx03
   60 * 7	 03 0F 01 \bx00 00 \wx01
Only thing is that I need one line per color.

PS: I’m using your stuff for almost twenty years now. I attached a small modification I made for the New Station’s stairs to give the impression of a road and station entrance under the tracks.
Attachments
Underbridge for Blunck's New Stations
Underbridge for Blunck's New Stations
new-stations--Unterfuehrung-ThomasGutmann.png (7.47 KiB) Viewed 3909 times
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Random colors on objects

Post by michael blunck »

GojkoG wrote: Thanks, Michael, it worked! [...]
Only thing is that I need one line per color.
Nice to hear!

Well, since "random action2" needs (c-ID) references as parameters there is no way around.

In m4nfo there are a number of auxiliary functions for simpler handling of  randomisation, but not for every case.

GojkoG wrote: I attached a small modification I made for the New Station’s stairs to give the impression of a road and station entrance under the tracks.
Thanks! I'll have to see how to include them in NewStation, codewise.

regards
Michael
Image
GojkoG
Engineer
Engineer
Posts: 14
Joined: 06 Dec 2017 18:45

Re: Random colors on objects

Post by GojkoG »

I know, that’s off-topic, but I didn’t expect to have a talk with you. If you plan to make an update of new stations, you may want to include my (not finished) pixelart for the portal of Berlin’s Anhalter Bahnhof. I don’t have the time to go on now, but would give you PNGs and Krita files.
(The station hall is my modification of your original from New Stations: windows more open and a gentle grid in the back—looked odd otherwise.)
Attachments
Berlin's old Anhalter Bahnhof by Thomas Gutmann
Berlin's old Anhalter Bahnhof by Thomas Gutmann
Anhalter-Bahnhof-20210713--Thomas-Gutmann.png (22.6 KiB) Viewed 3840 times
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Random colors on objects

Post by michael blunck »

Please see PM.

regards
Michael
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests