Update UndoRedoStack before calling events
Posted: Tue Feb 18, 2025 5:35 pm
I've been working with the UndoRedoStack for a few weeks now and it has a couple of glaring issues that are stopping me from doing much with it.
First is that it updates the stack after calling events (at least the ones I have tried, I don't know if it's true for every event). This prevents me from removing items from the stack until the next tick, where I have to iterate through it to remove whatever I want. Which would be fine, except if any player is using the editor while the game is paused, nothing would happen.
The second issue is adding items to the stack. Adding to the Undo stack is simple, if not hacky and destructive to the Redo stack. If i want to add a 'remove-entity' event, i can create the entity via scripting, then remove it and add the player's id in the method. However, this completely deletes the redo stack, which is sometimes unwarranted, but whatever. But there is no way to add items to the Redo stack whatsoever. Even a simple interface where it copies data from an existing entity, or modders need to pass a table full of data, would be appreciated. It would also be great to insert those actions wherever, in new items or into existing items.
First is that it updates the stack after calling events (at least the ones I have tried, I don't know if it's true for every event). This prevents me from removing items from the stack until the next tick, where I have to iterate through it to remove whatever I want. Which would be fine, except if any player is using the editor while the game is paused, nothing would happen.
The second issue is adding items to the stack. Adding to the Undo stack is simple, if not hacky and destructive to the Redo stack. If i want to add a 'remove-entity' event, i can create the entity via scripting, then remove it and add the player's id in the method. However, this completely deletes the redo stack, which is sometimes unwarranted, but whatever. But there is no way to add items to the Redo stack whatsoever. Even a simple interface where it copies data from an existing entity, or modders need to pass a table full of data, would be appreciated. It would also be great to insert those actions wherever, in new items or into existing items.