order_deconstruction and order_upgrade do not create undo orders

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
donlac
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Jun 01, 2021 1:51 am
Contact:

order_deconstruction and order_upgrade do not create undo orders

Post by donlac »

As I am making a mod that recurses thru all belt_neighbours to mark for deconstruction or upgrade all belts in a chain, I would like the users to be able to undo the deconstruction or upgrade like you can with the normal deconstruction and upgrade planners.

Can you either add to the undo list for entities which are marked by order_deconstruction and order_upgrade or provide a way to manually add an item to the undo list?
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: order_deconstruction and order_upgrade do not create undo orders

Post by FuryoftheStars »

My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
guardog
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Aug 02, 2022 7:49 pm
Contact:

Re: order_deconstruction and order_upgrade do not create undo orders

Post by guardog »

I would like to bump this request as I am encountering this limitation in my mod as well. Hope to spark more discussion on how to best integrate Undo function into our mods.

Similar threads
viewtopic.php?f=28&t=70393
Allow mods BP orders to be undo-able!

viewtopic.php?f=28&t=79210
LuaPlayer.build_history [RW]. A way to read and edit the undo queue

viewtopic.php?f=28&t=81936
undo triggers on_built_entity, can't tell if entity was made by undo

viewtopic.php?f=25&t=92143 - in Modding help
How to restore information for undo?

viewtopic.php?f=28&t=92413
allow storing tags in on_*_mined_entity event table for undo

viewtopic.php?f=28&t=98079
Collect undo-able actions from the same tick into one action.

Problems
  1. No control over undo queue as many scripted entity destruction do not go into the undo queue
    Barriers in implementing own undo queue:
  2. Unable to differentiate on_built_entity events by undo
  3. No link between deconstructed/mined entities and built entities - except by entity position. However, the problem above complicates implementation
Suggestions
  1. Expose more information in on_built_entity to differentiate built event due to undo, together with their link (maybe unit_number) to the supposedly mined/deconstructed entity. This will help mod authors who wish to implement their own undo queue by providing information for mod to react to built events triggered by undo
  2. API to manipulate undo queue - might be tricky when it comes to mod interactions
Further Suggestions
  1. API call for undo function. It will be useful to extend functionality of mods, or to automate tests involving undo handling.
Post Reply

Return to “Modding interface requests”