Page 1 of 1

[2.0.69] Custom input linked to `undo` game action doesn't fire on undo GUI shortcut

Posted: Sat Oct 04, 2025 5:46 pm
by The_LORD_thy_GOD
Reproduction steps:

1) Add the following prototype in data phase:

Code: Select all

data:extend({
	{
		type = "custom-input",
		name = "things-linked-undo",
		key_sequence = "",
		linked_game_control = "undo",
	},
})
2) In control phase, monitor when the above custom input fires, e.g.

Code: Select all

script.on_event("things-linked-undo", function() game.print("event fired") end)
3) Enter game and push 2 entries to the undo stack, e.g. by building 2 entities.

4) Push undo keybind (eg CTRL+Z) to undo the second entry

5) Push undo GUI button to undo the first entry

Actual result:
Pushing CTRL+Z will result in the event being fired. Pushing the undo GUI button will not fire the event.

Expected result:
Since in both cases the "undo" game action was triggered, the event should have fired in both cases.

Re: [2.0.69] Custom input linked to `undo` game action doesn't fire on undo GUI shortcut

Posted: Sun Oct 05, 2025 12:57 pm
by Rseding91
Thanks for the report however this is working correctly. A custom inputs are tied to the specific keyboard/mouse combination defined by the player and won't run when buttons are pushed.

Re: [2.0.69] Custom input linked to `undo` game action doesn't fire on undo GUI shortcut

Posted: Sun Oct 05, 2025 5:39 pm
by robot256
This is what the on_undo_applied event is for. Why do you need to link to the control instead?

Re: [2.0.69] Custom input linked to `undo` game action doesn't fire on undo GUI shortcut

Posted: Sun Oct 05, 2025 9:37 pm
by The_LORD_thy_GOD
`on_undo_applied` does not fire until after the operation is complete. I need an event that fires before. Event tracing reveals no such ordinary game event.

The custom input event does in fact fire at the needed time, but only if CTRL+Z is pressed. If the undo GUI button is pressed, it does not fire at all.

I thought that this was a bug since the custom input was linked to the "undo" game control rather than being bound to a key like an ordinary custom input would be. Now that it is confirmed not a bug, I suppose I will try a feature request instead.