Page 1 of 1

[2.0.6] Add argument to LuaControl::mine_entity for undo item_index

Posted: Fri Oct 18, 2024 8:59 pm
by robot256
Problem: Certain other methods, such as LuaEntity::order_deconstruction(), take "player" and "item_index" as arguments so that the action can be added or merged onto the undo-redo stack of the player. LuaControl::mine_entity() know what player is doing the action (the owner object) but does not take item_index as a parameter. Instead, it always creates a new undo item for every function call.

Proposed solution: I would like to pass item_index to the mine_entity() method so that it can add to the previous undo item. I use it inside on_player_mined_entity when the player mines a main entity to also have the player mine the object's component entities (e.g. cargo ship engine). The current behavior ends up adding individual invisible/non-placeable entities to the undo stack, and I have to remove them either from the stack or from the world when the non-placeable ghost is created. I would like to make all the component entities be in the same undo item as the originally-mined main entity.

Alternatively, a way to write back items to the undo-redo stacks would allow me to merge the item action lists manually.

(Edit: I also submitted this in an F10 suggestion)