[SOLVED] wesnoth.game_events and undoing moves.
Moderator: Forum Moderators
[SOLVED] wesnoth.game_events and undoing moves.
Hello,
the EventWML documentation describes allow_undo and on_undo direct action tags. However, there seems to be no equivalent for them in the LUA API, wesnorth.game_events.add and wesnoth.game_events.add_menu don't mention any option of allowing undo. wesnoth.game_events.add_repeating does have an optional argument on_undo, whose behaviours is not actually explained...
Recently I noticed an event I registered using wesnoth.game_events.add_repeating does prevent me from undoing, which is extremely irritating, because most of the time the event isn't doing anything, but it still prevents undos. I added the on_undo function to it, doing nothing at all, expecting that this will re-enable undos at the cost of the effects of the event not being properly undone, but this was not the case. The additional argument does not seem to change anything at all. Should I return something from this function in order to make undos possible? How does it work? Am I doomed to use wesnoth.game_events.add_wml whenever I want an undoable event?
the EventWML documentation describes allow_undo and on_undo direct action tags. However, there seems to be no equivalent for them in the LUA API, wesnorth.game_events.add and wesnoth.game_events.add_menu don't mention any option of allowing undo. wesnoth.game_events.add_repeating does have an optional argument on_undo, whose behaviours is not actually explained...
Recently I noticed an event I registered using wesnoth.game_events.add_repeating does prevent me from undoing, which is extremely irritating, because most of the time the event isn't doing anything, but it still prevents undos. I added the on_undo function to it, doing nothing at all, expecting that this will re-enable undos at the cost of the effects of the event not being properly undone, but this was not the case. The additional argument does not seem to change anything at all. Should I return something from this function in order to make undos possible? How does it work? Am I doomed to use wesnoth.game_events.add_wml whenever I want an undoable event?
Last edited by Sventimir on September 30th, 2025, 7:03 pm, edited 1 time in total.
- Celtic_Minstrel
- Developer
- Posts: 2410
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: wesnoth.game_events and undoing moves.
There definitely is an equivalent to that in the Lua API. Looks like we forgot to document it, though? It's
That's separate from allowing undo, which is handled by
wesnoth.game_events.add_undo_actions. I can see the [on_undo] tag calls it with some WML actions as the parameters; I think it might also support taking a Lua function, but I'm not sure.That's separate from allowing undo, which is handled by
wesnoth.experimental.game_events.set_undoable.Re: wesnoth.game_events and undoing moves.
I can see now that events don't prevent undos if they were filtered out by their filters. So in my case it's actually sufficient to use
wesnoth.game_events.add instead of wesnoth.game_event.add_repeating and provide a filter. That said it would still be very nice to have wesnoth.experimental documented somewhere in the LUA API section, unless it's not meant to be used by scenario creators yet.- Celtic_Minstrel
- Developer
- Posts: 2410
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [SOLVED] wesnoth.game_events and undoing moves.
I think
experimental means it's kinda ready to be used but not guaranteed to be stable. So, it should be fine to document it, with a warning note.