defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Post by LeonSkills »

Currently
defines.events.on_robot_mined_entity
defines.events.on_robot_built_entity
defines.events.on_robot_mined

are called (in that order), but not defines.events.on_robot_pre_mined

protocol_1903
Inserter
Inserter
Posts: 41
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Post by protocol_1903 »

ping. still not working in [1.1.104]. unrelated note, why are on_robot_mined and on_robot_mined_entity two different things? is on_robot_mined_entity supposed to act like on_robot_pre_mined?

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Post by Pi-C »

protocol_1903 wrote:
Sun Feb 18, 2024 8:35 am
why are on_robot_mined and on_robot_mined_entity two different things? is on_robot_mined_entity supposed to act like on_robot_pre_mined?
That's explained in the Lua-API description. on_robot_mined triggers when an entity (as opposed to a tile) has been mined. Also, on_robot_mined_entity acts like on_robot_post_mined: the entity has already been mined, but it still exists, so mods can access it. This can be useful when you are dealing with compound entities, where you have one main (visible) entity that the player communicates with and one or more (possibly hidden) auxiliary entities that provide special functionality. In this case, you could physically remove the auxiliary entities and clean up your tables when the event is triggered for the main entity.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

protocol_1903
Inserter
Inserter
Posts: 41
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Post by protocol_1903 »

Pi-C wrote:
Sun Feb 18, 2024 9:21 am
This can be useful when you are dealing with compound entities, where you have one main (visible) entity that the player communicates with and one or more (possibly hidden) auxiliary entities that provide special functionality. In this case, you could physically remove the auxiliary entities and clean up your tables when the event is triggered for the main entity.
You can do the exact same thing with on_robot_pre_mined. The entity is still accessible. The only difference is one has a buffer and one does not. It doesn't make sense, as both are redundant. Both only relate to entities. So why have both?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Post by Rseding91 »

pre_mined will get called several times as construction robots empty out the entity. on_mined will get called once with the results of mining the entity in the buffer.

So they have functional differences depending on what you are trying to do.
If you want to get ahold of me I'm almost always on Discord.

protocol_1903
Inserter
Inserter
Posts: 41
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Post by protocol_1903 »

Then why is it not called when upgrading an entity?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: defines.events.on_robot_pre_mined to be called when robot upgrades an entity

Post by Rseding91 »

protocol_1903 wrote:
Sun Feb 18, 2024 6:14 pm
Then why is it not called when upgrading an entity?
Because nobody added it when writing the upgrade entity logic.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding interface requests”