Page 1 of 1

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

Posted: Mon Dec 30, 2019 4:03 pm
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

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

Posted: Sun Feb 18, 2024 8:35 am
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?

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

Posted: Sun Feb 18, 2024 9:21 am
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.

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

Posted: Sun Feb 18, 2024 10:47 am
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?

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

Posted: Sun Feb 18, 2024 5:57 pm
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.

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

Posted: Sun Feb 18, 2024 6:14 pm
by protocol_1903
Then why is it not called when upgrading an entity?

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

Posted: Sun Feb 18, 2024 8:21 pm
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.