Creating custom colours

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

Moderator: Graphics Moderators

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

Creating custom colours

Post by 3iff »

Currently I am able to recolour some vehicles, mostly flatbed trucks, to indicate the class of cargoes they carry - it's just eye candy really.
However, it seems that I am limited to the default company colour set , ie PALETTE_CC_ORANGE (or blue, green, white and so on)

Is there any way I can create and use different colours from the palette? and if so, how can I do in in simple NML code?

I'm guessing it's either impossible or deceptively simple but my research has got me nowhere.

Thanks in advance...
Graion Dilach
Engineer
Engineer
Posts: 39
Joined: 28 Oct 2008 18:00
Location: Iszkaszentgyörgy, Hungary

Re: Creating custom colours

Post by Graion Dilach »

Here's an example: https://github.com/GraionDilach/univers ... #L155-L437

The additional company gradients are EmperorJake's NewCC though, so if you don't use GPLv2, you might not be able to use them. (I duplicate the company colors outright so that if a user enables NewCC, it will not affect my remap at all.)

In general though, you need to basically build up a list of gradient remaps with a reserve_sprites/replace combination and then build a similar switch block to easily refer the additional gradients - and then you can use those named switches exactly the way you'd use the current gradients. (You can reserve the sprites one by one as well, but that balloons the ActionD registers, so it's better if you reserve recolor sprites in blocks.)

I didn't really bother with 2cc though - it would basically follow this same principle, but would need to be a table in terms of allocation. I know how it would look in practice (I'd do a struct+CC table myself anyway, because I'm doing house NewGRFs), but couldn't be bothered to generate that combination table yet.
User avatar
3iff
Tycoon
Tycoon
Posts: 1116
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Creating custom colours

Post by 3iff »

That looks very useful. At least it gives me a place to start.
The requirement is for a vehicle set that won't be released so no licencing issues, but I generally use GPLv2 anyway.

Many thanks for taking the trouble to point me in the right place. I'll see if I can produce the effect I'm looking for.
User avatar
3iff
Tycoon
Tycoon
Posts: 1116
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Creating custom colours

Post by 3iff »

I can't get it to work.
The nml compiles fine but for flatbed goods trucks (my test example), I should get a red truck with a purple load but I get
a blue truck with a green load (which seems to be the default colours).

I create a custom colour but it doesn't seem to allow me to allocate/use it.
Graion Dilach
Engineer
Engineer
Posts: 39
Joined: 28 Oct 2008 18:00
Location: Iszkaszentgyörgy, Hungary

Re: Creating custom colours

Post by Graion Dilach »

My first guess would be an omission of the

Code: Select all

        recolour_mode: RECOLOUR_REMAP;
        palette: PALETTE_USE_DEFAULT;
block in the spritelayout but I guess you know that part already.

Can you PM me the NML snippets? I can take a look.
User avatar
3iff
Tycoon
Tycoon
Posts: 1116
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Creating custom colours

Post by 3iff »

No, I didn't know that.

I'll see if I can put it in the right place and I'll get you the code I'm playing with if that doesn't work.

Thanks.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 0 guests