Lua undo/redo actions

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Atria
Long Handed Inserter
Long Handed Inserter
Posts: 66
Joined: Sat Jul 09, 2016 10:25 am
Contact:

Lua undo/redo actions

Post by Atria »

Add support for new type of UndoRedoAction: "lua". New API function would have be created which would allow mods to register undoable actions which don't fit rest of undo/redo system.

So when mod wants to do something which currently isn't supported by undo/redo system the mod would call "player.undo_redo_stack.register_lua_undo()" instead and pass whatever parameters would be needed by the mod to undo/redo that action (dictionary of Any).

When user then undoes the action, normal "on_undo_applied" event would be triggered and mod would be able to do whatever it needs to undo the changes. Same goes for when user tries to redo that action.

Required API changes (unless I'm missing something):
  • New valid type of UndoRedoAction
  • New function to register undoable actions (probably on LuaUndoRedoStack)
Problems/open questions:
  • Not possible to preview undo/redo changes (unless that also could somehow be provided by the mod)
  • How to identify that mod should be processing specific "on_undo_applied" event?
    • Should mod only get its own lua undoable events in "on_undo_applied" or should it get all of them and UndoRedoAction would contain "mod_name" (which registered it) so mods can filter for their own events?
Post Reply

Return to “Modding interface requests”