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

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

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

Post 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.

Xcone
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Sep 29, 2018 9:09 am
Contact:

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

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Anachrony
Fast Inserter
Fast Inserter
Posts: 133
Joined: Thu Sep 21, 2017 10:55 pm
Contact:

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

Post 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.

Post Reply

Return to “Modding interface requests”