[Solved] How to apply animated graphics to chest?

Place to get help with not working mods / modding interface.
Post Reply
Schallfalke
Fast Inserter
Fast Inserter
Posts: 162
Joined: Sun Oct 28, 2018 7:57 am
Contact:

[Solved] How to apply animated graphics to chest?

Post by Schallfalke »

Hi all,

I want to apply animation to a chest (something like assembling machine, radar, turret, etc). I am using entity type "container" and "logistic-container" for it.
But I found out it supports only the property "picture", where I cannot use sub-properties like "frame_count" to apply animated graphics. (I know a lot on how to do animations on turrets though.)

1) Is there any way to apply animated graphics? Or how to get around the restriction?
2) Are there are any entity type that has the inventory/storage slots? I can change the entity type from "container" if it is needed.
Last edited by Schallfalke on Wed Jan 30, 2019 6:09 pm, edited 1 time in total.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to apply animated graphics to chest?

Post by DaveMcW »

You have to use two entities, one for the chest and one for the animation.

And then a bunch of control.lua code to make sure both entities are placed and removed together.

Schallfalke
Fast Inserter
Fast Inserter
Posts: 162
Joined: Sun Oct 28, 2018 7:57 am
Contact:

Re: How to apply animated graphics to chest?

Post by Schallfalke »

Does it mean I have to use some script to place an additional "animated entity" (like radar type) when item is placed, and remove the additional when it is mined?

I am not sure if it is tricky or not to place an entity on top of another. Can you show me some code on how to do that?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: How to apply animated graphics to chest?

Post by darkfrei »

prototype.pictures[1].priority = "extra-high"

It must be here https://wiki.factorio.com/Prototype/Entity but it does not. Same is here https://wiki.factorio.com/Types/RotatedSprite#priority

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

Re: How to apply animated graphics to chest?

Post by Bilka »

darkfrei wrote:
Sun Jan 20, 2019 7:03 pm
prototype.pictures[1].priority = "extra-high"
That has nothing to do with sprite drawing. It determines into what sprite atlas the sprite is put.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Schallfalke
Fast Inserter
Fast Inserter
Posts: 162
Joined: Sun Oct 28, 2018 7:57 am
Contact:

Re: How to apply animated graphics to chest?

Post by Schallfalke »

DaveMcW wrote:
Sun Jan 20, 2019 5:54 pm
You have to use two entities, one for the chest and one for the animation.

And then a bunch of control.lua code to make sure both entities are placed and removed together.
I have just tried that and it works, thanks for the suggestion.
I am now using a chest entity as "main" part. And a radar entity as animation part, which only creates when on_built_entity or on_robot_built_entity is called. (Similar for removal.)

But then a new problem arise. When holding the item in hand, the "green tint hover" (I don't know what it is called) only shows the chest entity sprite, without the radar entity sprite. It is the same problem, when ghosts are being placed, and in blueprints.
Is there a way to solve this too?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to apply animated graphics to chest?

Post by DaveMcW »

You could use a third entity that is a combination of both graphics, then destroy/replace it in on_built.

The nice thing is you can set main_entity.minable.result = "third_entity" so it goes back to the combined version when mined.

The only tricky part is blueprints, you will have to search/replace "main_entity" to "third_entity" in on_player_configured_blueprint.

Schallfalke
Fast Inserter
Fast Inserter
Posts: 162
Joined: Sun Oct 28, 2018 7:57 am
Contact:

Re: How to apply animated graphics to chest?

Post by Schallfalke »

Wow! You are so talented, thinking outside the box. :idea:

I have never tried modifying blueprint. This is a totally new area to me, it will take some time for me to look into that.

Have a new problem though. I want to set the radar-part entity to be invulnerable or "hide" from biters. Tried a few solutions but none of them works (biters still found and destroyed the radar entity), which include:
  • Setting prototype health to nil. (Setting zero reports error at game loading stage; setting to nil actually sets 10 health.)
  • Setting prototype collision box to {{0, 0}, {0, 0}}.
  • Setting property at surface.create_entity with destructible = false.
Is there any way to set entity invulnerability?


Post Reply

Return to “Modding help”