frame_count by animation's layer can be not same

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

frame_count by animation's layer can be not same

Post by darkfrei »

Hi!

Why are we need this limit, that layers must have same frame_count in the animation?
Now it's impossible, for example see data.raw.lab.lab.on_animation

It would be much better if the first layer is the base picture and another layers have small animation sprites, the same as it was done by furnace:

base picture:
data.raw.furnace["electric-furnace"].animation.layers

all propellers and heaters:
data.raw.furnace["electric-furnace"].working_visualisations[1].animation.frame_count = 12
data.raw.furnace["electric-furnace"].working_visualisations[2].animation.frame_count = 4

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: frame_count by animation's layer can be not same

Post by posila »

Why they have to be the same: Drawing system can draw only sprites (not animations), animation is just array of spites. Entity gets a frame of animation based on its state, and passes it to drawing system. Sprites can form linked lists (they have pointer to next sprite) and that's how layers are loaded. Drawing system then draws sprite it got and all sprites that are linked to it.
Why does it work this way? I don't know. It was like that when I got here. It probably slowly evolved into current state (something like: "how do we add support for multiple layers while changing as little code as possible? let's make sprites point to next layer sprite"). Does it need to be this way? No, but changing it would be major overhaul. <edit>Sprites having pointer to next layer sprite have advantage that any sprite anywhere can have layers. So it was not hard to add layers for item icons etc. If Animations would be aware of their layers, there would probably be still sprite linked lists, so there would be two systems for layers.</edit>

Since 0.16, animations can have repeat_count. It should be usable for what you need. Total frames of animation will be frame_count * repeat_count, and if you want tiny animation on big otherwise static sprite, you can define the main sprite as animation with frame_count = 1 and repeat_count equal to frame count of the tiny animation. See steam-turbine in base game, it is used for shadow layer there. (It might be buggy since it is not used very much, though)

Post Reply

Return to “Modding interface requests”