one image, multiple sprites, different colors?
one image, multiple sprites, different colors?
I want to programmatically create sprites to match the custom fluid colors in other mods. Can that be done?
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: one image, multiple sprites, different colors?
You can make use of the "tint" property to repurpose existing sprites into recolored ones.
For an example, you can check how the base game assembles biter/spitter/spawner sprites.
For an example, you can check how the base game assembles biter/spitter/spawner sprites.
Re: one image, multiple sprites, different colors?
Using the tint property will mean defining many different entities, but I'll just need one sprite image?
Is there a way to have just one entity and multiple colors of it?
Is there a way to have just one entity and multiple colors of it?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: one image, multiple sprites, different colors?
to properly use tint, you should recolour the image to white first in a program like photoshop. this will allow it to remap to any colour and look right, otherwise it'll skew and look off when using colours that aren't already in the entity.
Re: one image, multiple sprites, different colors?
Yeah, I've got it working with one white sprite and many entities with tinted pictures (https://github.com/sparr/factorio-mod-w ... lua#L7-L33)
Is there any way I can get one entity to show up in different colors?
Is there any way I can get one entity to show up in different colors?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: one image, multiple sprites, different colors?
Split your sprite into multiple parts, you can then use the layers definition to use multiple tint layers, and give each a different tint colour.
Re: one image, multiple sprites, different colors?
Can you give me an example of that? Say if I have one entity that I'd like to display in two different colors.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: one image, multiple sprites, different colors?
Look at the Biters.
The behemoth for example has green with orange stripes. These are all from one master set of Biter sprite sheets.
The behemoth for example has green with orange stripes. These are all from one master set of Biter sprite sheets.
Re: one image, multiple sprites, different colors?
The biters have a complex network of functions producing their entity definitions. I haven't been able to fully follow them
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: one image, multiple sprites, different colors?
Basically.....
Layer 1 would be the image that doesn't change colours at all.
Layer 2 would have a tint= tag that uses tint colour 1.
Layer 3 would have a tint= tag that uses tint colour 2.
That's about it.
It's pretty much just the same thing you'd do with adding 1 tint layer, but instead of just 1, you add 2. or 3... there's really no limit. (though practically, you don't want too many)
Code: Select all
animation={
layers={
{layer 1 definition},
{layer 2 definition},
{layer 3 definition}
}
}
Layer 2 would have a tint= tag that uses tint colour 1.
Layer 3 would have a tint= tag that uses tint colour 2.
That's about it.
It's pretty much just the same thing you'd do with adding 1 tint layer, but instead of just 1, you add 2. or 3... there's really no limit. (though practically, you don't want too many)
Re: one image, multiple sprites, different colors?
So once I define those layers, how do I pick a layer for an entity?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: one image, multiple sprites, different colors?
I don't understand the question... all layers would be on the entity simultaneously, they're drawn on top of each other.
I thought that's what you wanted, an entity that has more than one tint shown simultaneously.
I thought that's what you wanted, an entity that has more than one tint shown simultaneously.
Re: one image, multiple sprites, different colors?
No. I want one entity that can be blue or red, determined at run time.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: one image, multiple sprites, different colors?
That's what Tint does... though as far as I know, the tint is pre-set per entity. I think there's a tag (used on turrets, and maybe cars) that changes colour to match that of the player that placed it, but one that changes colour on runtime? I don't think that's possible.
Re: one image, multiple sprites, different colors?
I notice that many base decorative entities have multiple pictures. How are those selected between?
-
- Filter Inserter
- Posts: 478
- Joined: Sat Aug 23, 2014 11:43 pm
- Contact:
Re: one image, multiple sprites, different colors?
This won't work for all entities as not all support it.
You can use the property apply_runtime_tint which does the same as a tint but the color is determined by the color of the player who placed the entity which can be changed at runtime.
Here is an example of how to use it(code is from the gate)
Now when you want to change the color of your entity you just change the color of the player who placed the entity. To not change an actual playing players color you should make a dummy player and use it to place the entities for you.
You can use the property apply_runtime_tint which does the same as a tint but the color is determined by the color of the player who placed the entity which can be changed at runtime.
Here is an example of how to use it(code is from the gate)
Code: Select all
vertical_base =
{
layers =
{
{
filename = "__base__/graphics/entity/gate/gate-base-vertical.png",
width = 32,
height = 32
},
{
filename = "__base__/graphics/entity/gate/gate-base-vertical-mask.png",
width = 32,
height = 32,
apply_runtime_tint = true
}
}
}
Waste of bytes : P
Re: one image, multiple sprites, different colors?
That's a clever hack. Does the entity color change when the player's color changes later, or can I use one dummy player to set a bunch of entities to different colors one at a time?
-
- Filter Inserter
- Posts: 478
- Joined: Sat Aug 23, 2014 11:43 pm
- Contact:
Re: one image, multiple sprites, different colors?
The entities color changes the instant the players color changes which means you would need multiple players if you wanted different entities to be different colors.sparr wrote:That's a clever hack. Does the entity color change when the player's color changes later, or can I use one dummy player to set a bunch of entities to different colors one at a time?
Waste of bytes : P
Re: one image, multiple sprites, different colors?
Damn, that doesn't help, then. If I want 16 colors I have to create 16 entities or 16 players, no improvement either way. I'm trying to make fewer than 16 new things
-
- Filter Inserter
- Posts: 478
- Joined: Sat Aug 23, 2014 11:43 pm
- Contact:
Re: one image, multiple sprites, different colors?
In that case you could use cars. When you want a new color you just change the direction of the car because the car uses a different sprite for each direction. Set the cars property operable to false and remove the flags "pushable" and "placeable-off-grid" and then the car should behave like a static entity. use direction to change the direction of the car.sparr wrote:Damn, that doesn't help, then. If I want 16 colors I have to create 16 entities or 16 players, no improvement either way. I'm trying to make fewer than 16 new things
Have a look at how Nixie tubes uses a cars directions to change what the car looks like.
Waste of bytes : P