Page 1 of 1

scripted entities with wires and undo/redo

Posted: Fri Jan 30, 2026 6:28 pm
by hgschmie
I have a mod with entities under script control (let's call them "io pins"). those entities are created when a parent is created and deleted when that parent is deleted. These entities support connecting wires (copper, red, green).

I can blueprint my mod entities and build them. If these io pins have wires connected, they show up as ghosts and get put in place with blueprinting just fine.

If I undo construction, then all my entities disappear (internally I call LuaEntity#destroy() on them) and the wires disappear as well.

But when I "redo", then the wires are never reconstructed. Which is also clear; as the entities are controlled by the mod (create and destroy), they never are added to the undo/redo queue.

Is there a way for me to do that? Basically register those scripted entities as "when redoing, construct a ghost with the following wire connections". Basically I want to create a "wire-removed" action followed by a "removed-entity" action so when this gets undone, a ghost for the entity is created (I would deal with those the same way I deal with blueprint ghosts) and then the ghost is connected with wires.

Or is there a better way? Grateful for any pointers/help.