[2.0.12] on_object_destroyed fires after on_built_entity for quality upgraded entities

Quezler
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Fri Mar 25, 2016 6:37 pm
Contact:

[2.0.12] on_object_destroyed fires after on_built_entity for quality upgraded entities

Post by Quezler »

this caught me off guard, i had code that checks for the presence of a compound entity (or ghost) to adopt inside the on_built_entity hook, and i have on_object_destroyed handling to clear up the old compound entities, but in the case of upgrading the quality of something the upgraded quality fired it's on_built_entity hook before the previous quality triggered its deathrattle, which caused it to clean up its own internal entity even though the upgraded entity already started using it, modded my way around it by also checking for quality but it should probably be documented: https://github.com/Quezler/glutenfree/c ... ebe035eac0
curiosity
Filter Inserter
Filter Inserter
Posts: 484
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: [2.0.12] on_object_destroyed fires after on_built_entity for quality upgraded entities

Post by curiosity »

That's working as described. on_object_destroyed is raised "eventually", just like the old on_entity_destroyed, and the docs say it. on_built_entity is raised immediately.

This likely has nothing to do with quality either, a regular fast replace would be the same.
Quezler
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Fri Mar 25, 2016 6:37 pm
Contact:

Re: [2.0.12] on_object_destroyed fires after on_built_entity for quality upgraded entities

Post by Quezler »

> Depending on when a given object is destroyed, this event will be fired at the end of the current tick or at the end of the next tick.

fair, i guess it does kinda say that if you read between the lines, it doesn't really say its queued so i always interpreted it as "it'll fire when the object is removed, and the object being removed can be removed anywhere during the tick cycle"
curiosity
Filter Inserter
Filter Inserter
Posts: 484
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: [2.0.12] on_object_destroyed fires after on_built_entity for quality upgraded entities

Post by curiosity »

It does mention end of tick, at the same time you are not limited to when you can destroy objects. I think, it's clear enough.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 261
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: [2.0.12] on_object_destroyed fires after on_built_entity for quality upgraded entities

Post by Therenas »

Thanks for the discussion, I tried to make it a bit clearer for the next release.
Post Reply

Return to “Resolved Requests”