Make on_marked_for_deconstruction not fire before cloning events

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
guardog
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Aug 02, 2022 7:49 pm
Contact:

Make on_marked_for_deconstruction not fire before cloning events

Post by guardog »

Problem statement: Currently on 1.1.70, cloning an entity which has been marked for deconstruction will cause the marked_for_decons event to fire before the entity is cloned.

This behaviour can be observed by making a small test mod that handles both on_marked_for_deconstruction and on_entity_cloned events and then check the prints.
Capture.PNG
Capture.PNG (54.23 KiB) Viewed 1008 times
It becomes awkward for my mod to try to handle the deconstruction events first before knowing that the entity has been cloned.

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

Re: Make on_marked_for_deconstruction not fire before cloning events

Post by Rseding91 »

Sorry but there's no other way to do this that doesn't also have problems. Marking for deconstruction will send an event. If the entity is not marked before the cloned event is fired then the clone operation is not yet completed (source was marked, cloned isn't -> it's not done cloning.)
If you want to get ahold of me I'm almost always on Discord.

curiosity
Filter Inserter
Filter Inserter
Posts: 348
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Make on_marked_for_deconstruction not fire before cloning events

Post by curiosity »

Should the marked for deconstruction event even fire to begin with? There is no marking happening, the entity was already marked.

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

Re: Make on_marked_for_deconstruction not fire before cloning events

Post by Rseding91 »

Cloning is at the end of the day creating a new entity with all the same properties. If a mod wants to track things marked for deconstruction/upgrade it needs to get the event. I guess technically every mod that listens to those events could also listen to the cloned event and check them. But that would likely be a breaking change.
If you want to get ahold of me I'm almost always on Discord.

guardog
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Aug 02, 2022 7:49 pm
Contact:

Re: Make on_marked_for_deconstruction not fire before cloning events

Post by guardog »

curiosity wrote:
Sun Nov 06, 2022 1:23 pm
Should the marked for deconstruction event even fire to begin with? There is no marking happening, the entity was already marked.
Rseding91 wrote:
Sun Nov 06, 2022 2:44 pm
Cloning is at the end of the day creating a new entity with all the same properties.
Exactly why I made this request - my expectation was that all properties get cloned without needing to know what process the entity has gone through.

In my mod if something is marked for deconstruction, my mod handles the global data state change. When the same marked entity is cloned, my mod should be able to just clone the state without needing to do an awkward bypass for the marked for deconstruction event. The mark event firing before the clone event made it even more awkward - my mod has no knowledge of the entity during the mark event.

Post Reply

Return to “Modding interface requests”