Assembling machines and idle_animation

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Shenpen
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Aug 27, 2016 2:46 pm
Contact:

Assembling machines and idle_animation

Post by Shenpen »

So how do you make sure that your entity does not stop on a very active frame in the spritesheet?

I was trying to use idle animation, but as is clear now, that wont help.
So I need some other way of showing frame 1 when the assembler is idle....

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Do units use idle_animation at all?

Post by eradicator »

Shenpen wrote:
Tue Mar 09, 2021 7:30 pm
So how do you make sure that your entity does not stop on a very active frame in the spritesheet?

I was trying to use idle animation, but as is clear now, that wont help.
So I need some other way of showing frame 1 when the assembler is idle....
In modern versions you can use working_visualisations on assemblers too. Those don't render at all when idle. Ofc that requirest that you have the "very active" parts in a seperate sprite sheet than the (unanimated) base.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Shenpen
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Aug 27, 2016 2:46 pm
Contact:

Re: Do units use idle_animation at all?

Post by Shenpen »

eradicator wrote:
Wed Mar 10, 2021 6:06 am
Shenpen wrote:
Tue Mar 09, 2021 7:30 pm
So how do you make sure that your entity does not stop on a very active frame in the spritesheet?

I was trying to use idle animation, but as is clear now, that wont help.
So I need some other way of showing frame 1 when the assembler is idle....
In modern versions you can use working_visualisations on assemblers too. Those don't render at all when idle. Ofc that requirest that you have the "very active" parts in a seperate sprite sheet than the (unanimated) base.

Yes. I am looking for the syntax for redering the idle graphics.
The active part is not done with working_visualisations, but with [animation =]
Still the problem remains the same: It stops for idle status on random frame.
Also after making a copy that is done with working_visualisations.

User avatar
kirazy
Filter Inserter
Filter Inserter
Posts: 416
Joined: Tue Mar 06, 2018 12:18 am
Contact:

Re: Do units use idle_animation at all?

Post by kirazy »

Shenpen wrote:
Wed Mar 10, 2021 3:03 pm
Yes. I am looking for the syntax for redering the idle graphics.
The active part is not done with working_visualisations, but with [animation =]
Still the problem remains the same: It stops for idle status on random frame.
Also after making a copy that is done with working_visualisations.
Can you post your code for this entity?

If you have animation = your_idle_state, and working_visualisations = your_animated_state, then unless you have always_draw = true in your working visualisation, it should revert to your idle state when idle, e.g.:


User avatar
Shenpen
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Aug 27, 2016 2:46 pm
Contact:

Re: Do units use idle_animation at all?

Post by Shenpen »

kirazy wrote:
Thu Mar 11, 2021 11:48 am
Shenpen wrote:
Wed Mar 10, 2021 3:03 pm
Yes. I am looking for the syntax for redering the idle graphics.
The active part is not done with working_visualisations, but with [animation =]
Still the problem remains the same: It stops for idle status on random frame.
Also after making a copy that is done with working_visualisations.
Can you post your code for this entity?

If you have animation = your_idle_state, and working_visualisations = your_animated_state, then unless you have always_draw = true in your working visualisation, it should revert to your idle state when idle, e.g.:

Sure
flare-station.lua
(5.7 KiB) Downloaded 85 times

User avatar
Shenpen
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Aug 27, 2016 2:46 pm
Contact:

Re: Do units use idle_animation at all?

Post by Shenpen »

Code: Select all

animation = your_idle_state
That might be what I am looking for...

Example?

User avatar
kirazy
Filter Inserter
Filter Inserter
Posts: 416
Joined: Tue Mar 06, 2018 12:18 am
Contact:

Re: Do units use idle_animation at all?

Post by kirazy »

I'm looking at your code here and you have 49 frames for your idle animation? Hm. If it's just a single frame repeated 49 times you can use `repeat_count = 49` with `frame_count = 1` and a single image.

So the idle_animation field is a bit of a misnomer: it's not actually animated. Basically it means that when you transition from active to idle, the animation will pause on the shared frame number.

However! If you have fluid boxes, which I see that you do: basically the code logic can't tell the machine has gone to "sleep" due to the fluid logic, so idle_animation is never used:
posila wrote:
Tue Sep 15, 2020 10:33 am
The problem is the assembler has fluidboxes on it, so it doesn't go to sleep, and therefore the rendering doesn't consider the machine to be "idle".
It is definitelly an issue, I'll think about performance implications of making more expensive checks for being idle in rendering.
working_visualisations by contrast does know when an assembling machine has gone idle, even with fluid boxes, and so will turn off the animation unless you tell it to always_draw.

animation can be used here to be the idle state, since working_visualisation draws on top of animation, however you need to build your sprites specifically for this scenario, e.g. you have working_visualization be the animated portion of your sprite, and animation the non-animated portions, otherwise you have two sprites layered on top of each other.

This entity here https://github.com/Arch666Angel/mods/bl ... achine.lua is the one that was giving me trouble for much the same reasons you're experiencing, and I ended up constructing it with the following layers (but ALL in working_visualisations, though I don't remember why anymore):

working_vis 1: The "idle" state, set to `always_draw = true`
hr-strand-casting-machine-idle-state.png
hr-strand-casting-machine-idle-state.png (236.65 KiB) Viewed 3479 times
working_vis 2: The "recipe mask", which is colored with the recipe tint property, and set to `always_draw = true`
hr-strand-casting-machine-recipe-mask.png
hr-strand-casting-machine-recipe-mask.png (94.75 KiB) Viewed 3479 times
working_vis 3: The actual animation, which is drawn above the "idle" and "recipe mask" states when the machine is active
hr-strand-casting-machine-animation-frame.png
hr-strand-casting-machine-animation-frame.png (185.06 KiB) Viewed 3479 times
working_vis_4: The light that lights up the machine at night, which is likewise animated:
hr-strand-casting-machine-light-frame.png
hr-strand-casting-machine-light-frame.png (44.06 KiB) Viewed 3479 times
I don't know what your model looks like that you're trying to setup, I could give you pointers or ideas if you were to post it.

User avatar
kirazy
Filter Inserter
Filter Inserter
Posts: 416
Joined: Tue Mar 06, 2018 12:18 am
Contact:

Re: Do units use idle_animation at all?

Post by kirazy »

Ok, I downloaded your mod to check out your flare station.

This could be converted in the same way that the strand casting machine was converted. Just extract the glowing portion so that your animation is ONLY the glowing animated bits, and overlay that on a single frame that's your idle state. You could do it exactly how I did for the strand casting machine.

User avatar
Shenpen
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Aug 27, 2016 2:46 pm
Contact:

Re: Do units use idle_animation at all?

Post by Shenpen »

kirazy wrote:
Thu Mar 11, 2021 8:56 pm
Ok, I downloaded your mod to check out your flare station.

This could be converted in the same way that the strand casting machine was converted. Just extract the glowing portion so that your animation is ONLY the glowing animated bits, and overlay that on a single frame that's your idle state. You could do it exactly how I did for the strand casting machine.
That sounds like the way to go then!
Thank you for taking your time looking into this!



Just disecting a bit:
As I read you, this is the single frame idle version of the casting mashine, drawn from strand-casting-machine-idle-state.png.

Code: Select all

working_visualisations = {
        {
          always_draw = true,
          animation = {
            layers = {
              {
                filename = "__angelssmelting__/graphics/entity/strand-casting-machine/strand-casting-machine-idle-state.png",
                priority = "high",
                width = 167,
                height = 197,
                shift = util.by_pixel(0, -16.5),
                hr_version = angelsmods.trigger.enable_hq_graphics and {
                  filename = "__angelssmelting__/graphics/entity/strand-casting-machine/hr-strand-casting-machine-idle-state.png",
                  priority = "high",
                  width = 329,
                  height = 392,
                  shift = util.by_pixel(0, -16.5),
                  scale = 0.5
                } or nil
              },
              {
                filename = "__angelssmelting__/graphics/entity/strand-casting-machine/strand-casting-machine-shadow.png",
                priority = "high",
                width = 223,
                height = 157,
                draw_as_shadow = true,
                shift = util.by_pixel(29.5, 3.5),
                hr_version = angelsmods.trigger.enable_hq_graphics and {
                  filename = "__angelssmelting__/graphics/entity/strand-casting-machine/hr-strand-casting-machine-shadow.png",
                  priority = "high",
                  width = 444,
                  height = 311,
                  draw_as_shadow = true,
                  shift = util.by_pixel(29.5, 3.5),
                  scale = 0.5
                } or nil
              }
            }
          }
        },

And this is your animated active visualisation, drawn on top (or more complicated based on masks) and based on a multi-frame spritesheet:

Code: Select all

    {
          fadeout = true,
          animation = {
            filename = "__angelssmelting__/graphics/entity/strand-casting-machine/strand-casting-machine-working-animation.png",
            priority = "high",
            width = 167,
            height = 197,
            line_length = 6,
            frame_count = 24,
            animation_speed = 0.5,
            shift = util.by_pixel(0, -16.5),
            hr_version = angelsmods.trigger.enable_hq_graphics and {
              filename = "__angelssmelting__/graphics/entity/strand-casting-machine/hr-strand-casting-machine-working-animation.png",
              priority = "high",
              width = 329,
              height = 392,
              line_length = 6,
              frame_count = 24,
              animation_speed = 0.5,
              shift = util.by_pixel(0, -16.5),
              scale = 0.5
            } or nil

"I don't know what your model looks like"

No model, just decorating the base-mod spritesheet a bit. I have no skills in 3D modeling.

User avatar
kirazy
Filter Inserter
Filter Inserter
Posts: 416
Joined: Tue Mar 06, 2018 12:18 am
Contact:

Re: Do units use idle_animation at all?

Post by kirazy »

This will accomplish what you are looking for:

Code: Select all

working_visualisations = {
    -- Idle state
    {
        always_draw = true,
        animation = {
            filename = "__bitumen__/graphics/entity/flare-station/flare_station_idle.png",
            priority = "high",
            width = 300,
            height = 300,
            shift = util.by_pixel(0, -0.5),
            scale = 0.36, --from 33
        }
    },

    -- Animated state
    {
        fadeout = true,
        animation = {
            filename = "__bitumen__/graphics/entity/flare-station/flare_station.png",
            priority = "high",
            width = 300,
            height = 300,
            frame_count = 49,
            line_length = 7,
            shift = util.by_pixel(0, -0.5),
            scale = 0.36, --from 33
            animation_speed = 0.20,
        }
    },
}
You'll want to of course make the sprite sheets to go with it, and maybe add `hr_version`, but otherwise that should do the trick.

Though, looking at your files, your files are the HR version, so you don't need to make a separate entry that repeats the information just to specify `hr_version` the way you currently do. You only need to specify both sets of sprite references for normal and hr if you have actually different sprites for both graphics options. If you just have the one, just use the normal definition.

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Assembling machines and idle_animation

Post by Bilka »

I split this topic from the original topic which was about unit idle_animations. They're both useful topics, but it gets a bit confusing when entity prototypes that work very differently are mixed in one thread.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Shenpen
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Aug 27, 2016 2:46 pm
Contact:

Re: Do units use idle_animation at all?

Post by Shenpen »

kirazy wrote:
Fri Mar 12, 2021 10:01 am
This will accomplish what you are looking for:

Code: Select all

working_visualisations = {
    -- Idle state
    {
        always_draw = true,
        animation = {
            filename = "__bitumen__/graphics/entity/flare-station/flare_station_idle.png",
            priority = "high",
            width = 300,
            height = 300,
            shift = util.by_pixel(0, -0.5),
            scale = 0.36, --from 33
        }
    },

    -- Animated state
    {
        fadeout = true,
        animation = {
            filename = "__bitumen__/graphics/entity/flare-station/flare_station.png",
            priority = "high",
            width = 300,
            height = 300,
            frame_count = 49,
            line_length = 7,
            shift = util.by_pixel(0, -0.5),
            scale = 0.36, --from 33
            animation_speed = 0.20,
        }
    },
}
You'll want to of course make the sprite sheets to go with it, and maybe add `hr_version`, but otherwise that should do the trick.

Though, looking at your files, your files are the HR version, so you don't need to make a separate entry that repeats the information just to specify `hr_version` the way you currently do. You only need to specify both sets of sprite references for normal and hr if you have actually different sprites for both graphics options. If you just have the one, just use the normal definition.
Thanks man!

I know the double entry is a bit of a mess. But it might come in handy if I take time out to go over the files and make the needed downscaled versions for any potato-jockeys out there. Not everyone have a new computer and an expensive graphics card.

Post Reply

Return to “Modding help”