[2.0.45] UndoRedoStack is not updated until after on_player_mined_entity

We are aware of them, but do not have solutions that don't cause other issues. They go here in order not to take space in the main bug thread list.
BurninSun
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Fri Mar 16, 2018 4:54 am
Contact:

[2.0.45] UndoRedoStack is not updated until after on_player_mined_entity

Post by BurninSun »

When a player mines an entity, on_player_mined_entity event is triggered but the undo/redo stack is not updated yet with the newly mined entity. This causes a problem if the entity being mined has custom tags.

I would like to collect those tags within the on_player_mined_entity event and use LuaUndoRedoStack::set_undo_tag(...) to set those tags onto the entity within the undo stack. Then when the player triggers an undo, I can read those tags back in order to setup the custom entity correctly. The problem is that the undo stack isn't updated until after the original entity is destroyed, including its tags.

There would need to be similar consideration for on_player_mined_tile.

Alternatively (this would be a modding interface request) would it be possible to have a pointer to the undo/redo stack item included in the event data for all events that update the undo/redo stack?
Rseding91
Factorio Staff
Factorio Staff
Posts: 15867
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.45] UndoRedoStack is not updated until after on_player_mined_entity

Post by Rseding91 »

Thanks for the report however I don't think this is addressable. Looking into the logic, the order that thing happen and the split between the two functions in code means it just doesn't work to update the undo/redo stack before the event runs.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Minor issues”