Allow mod to track entities across undo
Posted: Wed Apr 26, 2023 5:36 pm
It is often desirable to attach some data to an entity, this can be done for instance, with a table by unit_number in global.
However an entity is deleted, then the deletion is un-done. there is no way to remember or recover this data. The unit number changes, there's no other identifying info.
The workaround I've seen used is to have a "dummy-combinator" holding the settings with the actual functional entities being hidden. However, this doesn't work with "attaching" data to vanilla/existing entities.
Some ways that this could be done:
- Provide another "unit_number" thing, such as, "id_number", that stays the same for an entity when it is deleted/undo, died/revived, etc..
- Better, the dream would to let entities to have "custom_tags" that lives and dies with the entity, like the "tags" for blueprint ghosts, but for all entities; this would live through undo, die/revive.
- An extension of the previous idea, let the "custom_tags" be copy/paste-able through blueprinting too. This would also make it much, much easier for mods to store custom entity settings in blueprints, and allow multiple mods to do so simultaneously.
The last option seems like the most logical option. I don't know why it hasn't been done like this previously, but I'll trust the devs have their reasons for it.
However an entity is deleted, then the deletion is un-done. there is no way to remember or recover this data. The unit number changes, there's no other identifying info.
The workaround I've seen used is to have a "dummy-combinator" holding the settings with the actual functional entities being hidden. However, this doesn't work with "attaching" data to vanilla/existing entities.
Some ways that this could be done:
- Provide another "unit_number" thing, such as, "id_number", that stays the same for an entity when it is deleted/undo, died/revived, etc..
- Better, the dream would to let entities to have "custom_tags" that lives and dies with the entity, like the "tags" for blueprint ghosts, but for all entities; this would live through undo, die/revive.
- An extension of the previous idea, let the "custom_tags" be copy/paste-able through blueprinting too. This would also make it much, much easier for mods to store custom entity settings in blueprints, and allow multiple mods to do so simultaneously.
The last option seems like the most logical option. I don't know why it hasn't been done like this previously, but I'll trust the devs have their reasons for it.