use game_events.add in on_event.lua
previously on_event.lua and game_events.add had separate priority lists, so that independent of the priority parameter (which both game_events.add and on_event.lua now support) on_event.lua events were always executed first.
The set_undoable(true) call is there to match the previous behavior of on_event.lua where events implemented via on_event were undoable by default.
The higher default priority of 0.5 is there to match the previous behavior of on_event.lua where events implemented via on_event.lua were always run before wml events.
Fixes#6898. The issue is that non-WML events added through the new events API
always disable undo with no equivalent of WML's `[allow_undo]`. The long-term
fix is to add a way to do that; however until that's available then listeners
for `moveto` need to use the old `on_event` API. The old `on_event` API can't
be deprecated yet, and this is enforced by our unit tests (the build fails if
there are unexpected deprecation warnings during the tests).
Reverts most of 7e234f8833. Does not revert files
that only listen for non-undoable events such as `die` or `new turn`.
Reverts the deprecation part of #5663's 8cd1332630.
Basically this means each of the call modes of the old function is now a separate function.
- add_repeating and add_menu take an ID and a function
- add_wml takes variable substitution setting and a config
- add takes the full options table
Unlike the old wesnoth.game_events.on_event hook and the "convenient" on_event() wrapper for it, this new functionality supports all of the features of WML events, with the sole exception of serialization, since it's not possible to reliably serialize a Lua function.
This commit also divorces menu items from the event that they trigger. The undocumented wesnoth.interface.set_menu_item function no longer adds an event for the menu item; the caller needs to separately register an event using the new functionality.
actual bugs found:
* backwards_compatibility.lua (undeclared global "helper")
* core.lua (use of undeclared global "helper")
* wml_tags.transform_unit had wrong code to deal with recall_cost
* wrong variable name in cave_map_generator
Added some features:
1) on_event now supports a comma separated list of event names in its first parameter
2) on_event now supports a number as second parameter that specifies in which order the event handlers are called.
3) on_event now passes wesnoth.current.event_context to the handler function, since the handler function will most likeley need it.