Page 1 of 1

LuaPlayer.build_history [RW]. A way to read and edit the undo queue

Posted: Sun Dec 22, 2019 6:37 pm
by LeonSkills
Is it possible to get read/write access to the recent build history of a player?

I created a selection tool that deletes, upgrades and creates some entities, and would like it to work with the undo function.

So some way to add a list of entities to be built, upgraded and or deconstructed to the build history queue.

Re: LuaPlayer.build_history [RW]. A way to read and edit the undo queue

Posted: Mon Apr 27, 2020 11:36 am
by Xcone
I would like something similar as well.

I'm in the proces of making a mod that places ghosts from a selection-tool (https://github.com/Xcone/factorio_pump see the gif there).
`LuaSurface.create_entity()` does not create those entities in undo-able fashion.
If support for undo is added I would really like the placements of all ghosts to be undoable in one press. After all, it's only one action the player does that causes the mod to place all the ghosts at once.

I have no clue what would work well with the existing implementation of undo, but maybe something like:
- local my_token = player.begin_undo()
- surface.create_entity{undo_token=my_token}
This would allow to provide the same token to other methods that might support undo, and therefor allow the modder to combine a lot of actions into a single undo-able action. Or allow the modder to make 2 separate undo tokens, for 2 separate undo actions (being undone in reverse order the tokens were requested).
This also prevents the need to expose direct manipulation of the undo queue (which I think would be risky/messy).
- The token could be finished by player.end_undo(my_token) explicitly, or implicitly at the end of the frame or after a short time delay.

Re: LuaPlayer.build_history [RW]. A way to read and edit the undo queue

Posted: Mon Apr 26, 2021 5:09 pm
by eradicator
+∞

It's frustrating to hit this kind of wall while trying to make a good mod that feels like proper vanilla. Without some sort of undo access all mods will eternally be sub-par quality.

Related topics:
Allow mods BP orders to be undo-able!, Collect undo-able actions from the same tick into one action.

Re: LuaPlayer.build_history [RW]. A way to read and edit the undo queue

Posted: Thu Dec 09, 2021 8:41 am
by Anachrony
This should probably be merged with this very similar request:
viewtopic.php?f=28&t=70393

I'm running into this same issue. My mod has lots of entities that are modified or replaced by script, and there is no interface for maintaining the ctrl+Z undo queue, so you just can't undo building a wide range of modded entitites.