Update UndoRedoStack before calling events

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
protocol_1903
Filter Inserter
Filter Inserter
Posts: 275
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Update UndoRedoStack before calling events

Post by protocol_1903 »

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.
If you need to reach me, message me on discord.

I make qol mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
If you have a mod idea, I can look into it.
Post Reply

Return to “Modding interface requests”