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

Bugs that are actually features.
The_LORD_thy_GOD
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sun Nov 10, 2024 5:23 pm
Contact:

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

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16155
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
robot256
Smart Inserter
Smart Inserter
Posts: 1288
Joined: Sun Mar 17, 2019 1:52 am
Contact:

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

Post by robot256 »

This is what the on_undo_applied event is for. Why do you need to link to the control instead?
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
The_LORD_thy_GOD
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sun Nov 10, 2024 5:23 pm
Contact:

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

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

Return to “Not a bug”