New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support event priority in the WML event pump #7582
Comments
I don't believe The event handling system does not have a concept of priority as of right now. The commit you linked is a separate Lua-only event handling system that was sort of a hack to work around a lack of Lua API to the actual event handling system. We should definitely support priority in the real event handling system though. |
I might have used the wrong wording, but this is what I mean: [event]
name=moveto
[fire_event]
name=return_please
[/fire_event]
[message]
message="Made it back"
[/message]
[/event]
[event]
name=return_please
[return][/return]
[/event] The idea is not allowing the
Oh! That's an unfortunate state of affairs. |
I strongly support adding such a key to events, In particular to give independent addons/modules a way to coordinate their events, when they register handlers to the same event.
I think in your case the [return] has no effect
I don't think that'd be expected bahviour by most wml developers, and not something that should be changed, |
Well, that's how it works in Stable.
The current behavior has been documented since 2017. https://wiki.wesnoth.org/index.php?title=InternalActionsWML&diff=58736&oldid=58389 Althought it's apparent that exiting just one event handler is a missing feature. |
It might be covered by
While the name may be slightly unfortunate, given that it's already documented and working that way, we probably can't change it. My interpretation of what you said was more like this:
Where, just like in your example, "Made it back" is never reached. That's why I mentioned |
I see. In a web context, that would be the difference between |
I think the real reason |
Hmm okay, i mean i probably won't care that much since i write most of my events in lua these days anyways |
Well, IMO, the current behavior of aborting the entire event stack
As for
Anyway... Any more thoughts about priority? |
To be honest I'm confused what's being proposed. It sounds like there's really two features:
|
That's the subject of the issue.
Those are tangentially-related use cases, which kinda hijacked this thread. |
Since So, I'm marking this higher priority. |
It is the second argument to on_event thoughso if the main purpose is to be drop in replacement for on_event it should probably be also the second parameter there. |
So the final signature will be |
Just for the record I really dislike our tendency to make difficult to understand lua interfaces by putting optional arguments before required ones or allowing locations as single or multiple arguments. Great if that is theoretically unambiguously possible. Still a bad idea in terms of clarity in my book. |
This is pretty normal in Lua, even the most often used standard function |
It still makes it harder to understand, whether it's common in lua or not. |
Might as well deprecate |
Deprecation is awaiting #7566 |
OK. Point is that newer APIs should be designed to supercede old APIs, not to mimick them. If the new API would require a bad signature in order to be a drop-in replacement to Instead, the old API is kept and routed through the new API, and the old API is eventually deprecated, and removed. |
Yes, if we prefer to reorder the arguments, So, basically, you're correct that we don't need to preserve the same order that |
I don't think that a second optional argument is harder to understand. I however think that code like
is quite hard to read, |
That does actually make sense to me as an argument for putting the priority before the function… |
Describe the desired feature
ac717f7 added event priority support to Lua, which reached Stable in 1.14.
Fast-forward today, and customization of WML events is still very precarious (
[fire_event][data]
was just introduced in 1.17.6). Support forpriority
attribute in[event]
tags would be very helpful and open many possibilities:[return]
in order to cancel events.[event]
execution timing from file/line placements, in case there are several listeners to the same event name.The text was updated successfully, but these errors were encountered: