[wesnoth-commits] [wesnoth/wesnoth] 212264: Events are now a Lua function instead of WML

Celtic Minstrel noreply at github.com
Mon Apr 26 05:39:55 UTC 2021


  Branch: refs/heads/lua_events
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 21226430c9673850224b21267b75fa433e99e1f4
      https://github.com/wesnoth/wesnoth/commit/21226430c9673850224b21267b75fa433e99e1f4
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/game_events/handlers.cpp
    M src/game_events/handlers.hpp
    M src/game_events/manager.cpp
    M src/game_events/manager.hpp
    M src/game_events/manager_impl.cpp
    M src/game_events/manager_impl.hpp
    M src/game_events/menu_item.cpp
    M src/game_events/menu_item.hpp
    M src/game_events/wmi_manager.cpp
    M src/game_events/wmi_manager.hpp
    M src/game_state.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp
    M src/units/unit.cpp

  Log Message:
  -----------
  Events are now a Lua function instead of WML

The function is specified by [event]code= and will be passed the entire contents of the [event] tag (including the code itself).

If code= is omitted, a default is supplied which runs ActionWML; however, internally it is still a function rather than a list of ActionWML commands.


  Commit: 01b0e0ea389336696449c7373594c555e2194f4f
      https://github.com/wesnoth/wesnoth/commit/01b0e0ea389336696449c7373594c555e2194f4f
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/lua/core/interface.lua
    M data/lua/on_event.lua
    M data/lua/wml-tags.lua
    M src/game_events/entity_location.cpp
    M src/game_events/entity_location.hpp
    M src/game_events/handlers.cpp
    M src/game_events/handlers.hpp
    M src/game_events/manager.cpp
    M src/game_events/manager.hpp
    M src/game_events/manager_impl.cpp
    M src/game_events/manager_impl.hpp
    M src/game_events/menu_item.cpp
    M src/game_events/pump.cpp
    M src/game_events/pump.hpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp
    M src/scripting/push_check.hpp
    M src/side_filter.hpp

  Log Message:
  -----------
  Enable setting an arbitrary Lua function as an event handler.

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.


  Commit: 37e2d0e890982fa050b4f45a4b52569bbec7784a
      https://github.com/wesnoth/wesnoth/commit/37e2d0e890982fa050b4f45a4b52569bbec7784a
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    A data/test/scenarios/test_lua_name.cfg
    M src/scripting/lua_kernel_base.cpp
    M wml_test_schedule

  Log Message:
  -----------
  Fix load_string() ignoring the passed chunk name

Complete with a unit test!


  Commit: 615e302c341d21bc03690fd582c4f6e254661bc7
      https://github.com/wesnoth/wesnoth/commit/615e302c341d21bc03690fd582c4f6e254661bc7
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/formula/callable_objects.cpp

  Log Message:
  -----------
  WFL: Add recall list to the side object


  Commit: 04868d02f73ec5c7daea936f7587b2c8484898fc
      https://github.com/wesnoth/wesnoth/commit/04868d02f73ec5c7daea936f7587b2c8484898fc
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/ai/formula/ai.cpp
    M src/formula/callable_objects.cpp
    M src/formula/callable_objects.hpp
    M src/game_events/handlers.cpp
    M src/game_events/manager.cpp

  Log Message:
  -----------
  Add [event]filter_formula= for WFL event filtering


  Commit: aa189580c7641f3e8fc4a6144f64070af6515e57
      https://github.com/wesnoth/wesnoth/commit/aa189580c7641f3e8fc4a6144f64070af6515e57
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/game_events/handlers.cpp
    M src/game_events/manager.cpp
    M src/play_controller.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp

  Log Message:
  -----------
  Support Lua event filters as [event]filter= with [filter_args]

This also supports passing an arbitrary Lua function as the filter when the event is registered from Lua.


  Commit: cdd47d6c5c36192c3bdb676eaf6db0b905871253
      https://github.com/wesnoth/wesnoth/commit/cdd47d6c5c36192c3bdb676eaf6db0b905871253
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/lua/core/interface.lua
    M data/lua/wml-tags.lua
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Move the event firing functions to wesnoth.game_events

* These functions take the full event data config as the final argument, rather than just the weapon info subconfigs.
* The [fire_event] tag now supports a [data] tag that can add additional data to the event, for example damage_inflicted. The [primary_attack]  and [secondary_attack] tags are still supported and are not deprecated.
* wesnoth.current.event_context now has a data child which holds the full event data. It still duplicates common info (weapons and damage inflicted) in the same way as before.


  Commit: 1327fe29125cf581f89b4cd561d22a5e69a8bca7
      https://github.com/wesnoth/wesnoth/commit/1327fe29125cf581f89b4cd561d22a5e69a8bca7
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/game_events/handlers.cpp
    M src/game_events/handlers.hpp
    M src/play_controller.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp

  Log Message:
  -----------
  Improve the handling of event serialization when Lua code is attached

- Don't try to serialize an event with a Lua filter (ie, add{filter = function() end})
- Write the serialization warning to in-game chat, but ONLY if the event was registered after preload


  Commit: 6cf1553419e54d5a86253cb4c1e79db3f069b296
      https://github.com/wesnoth/wesnoth/commit/6cf1553419e54d5a86253cb4c1e79db3f069b296
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Adding an event handler via the positional call style now defaults to a repeating event

This is a somewhat controversial change!

PROS:
- This makes wesnoth.game_events.add a drop-in replacement for the on_event function
- If you're registering events in preload, most of them WILL be repeating events

CONS:
- This makes the default depend on the call style; in positional style, it defaults to repeating, and in named-argument style, it defaults to non-repeating
- This makes the default different from the WML default of non-repeating events


  Commit: adc7d8480412f87c9c73dc45aca1929bc5bd7292
      https://github.com/wesnoth/wesnoth/commit/adc7d8480412f87c9c73dc45aca1929bc5bd7292
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    A data/test/scenarios/events-test_actions.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Unit tests for each way of assigning an action to an event handler


  Commit: eada04d4a85b1216dedc962cce9c8f3d050aaf82
      https://github.com/wesnoth/wesnoth/commit/eada04d4a85b1216dedc962cce9c8f3d050aaf82
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_filters.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Unit tests for the new filter options


  Commit: 0a368b0bf98a678a6dce7adbff3583edd2d4bd7b
      https://github.com/wesnoth/wesnoth/commit/0a368b0bf98a678a6dce7adbff3583edd2d4bd7b
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/lua/wml-tags.lua

  Log Message:
  -----------
  Update [remove_event] to use new API


  Commit: 0130021f3ae2a49dbac423285d7ea5780f1320bc
      https://github.com/wesnoth/wesnoth/commit/0130021f3ae2a49dbac423285d7ea5780f1320bc
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/event_handlers_in_events.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Unit test to verify that [event]delayed_variable_substitution=no works


  Commit: a6c7130510dd6421dfb9ac655b8b83071c81a1ff
      https://github.com/wesnoth/wesnoth/commit/a6c7130510dd6421dfb9ac655b8b83071c81a1ff
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/schema/core/addons.cfg

  Log Message:
  -----------
  Update schema for the new [event] options


  Commit: 0cdb145e9d333251a62957df99a47d1380c87d82
      https://github.com/wesnoth/wesnoth/commit/0cdb145e9d333251a62957df99a47d1380c87d82
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/formula/callable_objects.hpp

  Log Message:
  -----------
  Delete TODO that isn't relevant after all


  Commit: 3ab2cee51fab7dd03a24e6dd40f0e686eb217448
      https://github.com/wesnoth/wesnoth/commit/3ab2cee51fab7dd03a24e6dd40f0e686eb217448
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/formula/callable_objects.hpp

  Log Message:
  -----------
  Convert gamestate_callable comment to Doxygen


  Commit: c43f36deec42dadbf2ac8a9c60fb0b22a474bcdc
      https://github.com/wesnoth/wesnoth/commit/c43f36deec42dadbf2ac8a9c60fb0b22a474bcdc
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/formula/callable_objects.hpp

  Log Message:
  -----------
  Convert event_callable comment to Doxygen


  Commit: 94fa81516569f7f3c124a6daf5d75a187df5b70c
      https://github.com/wesnoth/wesnoth/commit/94fa81516569f7f3c124a6daf5d75a187df5b70c
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/game_events/entity_location.cpp

  Log Message:
  -----------
  Remove a line break in a function header


  Commit: bffe1247559348d29ecddbc979d229372b0eefd8
      https://github.com/wesnoth/wesnoth/commit/bffe1247559348d29ecddbc979d229372b0eefd8
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/game_events/manager_impl.hpp

  Log Message:
  -----------
  Adjust Doxygen comment style in pending_event_handler


  Commit: 201a15b86a1a2ba41a6c91070736ea3d7d28c4ed
      https://github.com/wesnoth/wesnoth/commit/201a15b86a1a2ba41a6c91070736ea3d7d28c4ed
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/game_events/manager.hpp

  Log Message:
  -----------
  Remove spurious line break from Doxygen comment for add_event_handler_from_lua


  Commit: 268d90bdaebaf2193241b5988b45b3a50478594f
      https://github.com/wesnoth/wesnoth/commit/268d90bdaebaf2193241b5988b45b3a50478594f
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M src/game_events/handlers.cpp
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Rename [event]code= to [event]action=


  Commit: 2999513fac0ef51b13d50125030968086f73f43c
      https://github.com/wesnoth/wesnoth/commit/2999513fac0ef51b13d50125030968086f73f43c
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_actions.cfg

  Log Message:
  -----------
  Update action unit tests to use action=


  Commit: 55dbbf5c3374d4c6bf1e11ef26dc66e0b900e9dd
      https://github.com/wesnoth/wesnoth/commit/55dbbf5c3374d4c6bf1e11ef26dc66e0b900e9dd
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_filters.cfg

  Log Message:
  -----------
  Update filter unit tests to use action=


  Commit: f92a22f052aceeea021b43a6d73a6888e20279d0
      https://github.com/wesnoth/wesnoth/commit/f92a22f052aceeea021b43a6d73a6888e20279d0
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/test_lua_name.cfg

  Log Message:
  -----------
  Update lua_name unit test to use action=


  Commit: d99ac34d33b3bf2470e1fe333913d4ceec78739d
      https://github.com/wesnoth/wesnoth/commit/d99ac34d33b3bf2470e1fe333913d4ceec78739d
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_actions.cfg
    M src/game_events/handlers.cpp
    M wml_test_schedule

  Log Message:
  -----------
  Add a warning if an [event] contains both ActionWML and an action= that doesn't check its arguments (the ... variable)


  Commit: 6b463044942d9457fb57afdeca3986a6d527bc65
      https://github.com/wesnoth/wesnoth/commit/6b463044942d9457fb57afdeca3986a6d527bc65
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_actions.cfg

  Log Message:
  -----------
  Replace pass_if in action tests


  Commit: a66ef5c42b9aa9a1717f9a8b83726dde9ac84eb4
      https://github.com/wesnoth/wesnoth/commit/a66ef5c42b9aa9a1717f9a8b83726dde9ac84eb4
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_filters.cfg

  Log Message:
  -----------
  Replace pass_if in filter tests


  Commit: 863cb1d9ae4456c002a962bf55f210406828495f
      https://github.com/wesnoth/wesnoth/commit/863cb1d9ae4456c002a962bf55f210406828495f
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-25 (Sun, 25 Apr 2021)

  Changed paths:
    M data/test/scenarios/test_lua_name.cfg

  Log Message:
  -----------
  Replace pass_if in lua_name test


  Commit: 1c29559c8d02bd7ff25f5c0875ee075ec55fb3ae
      https://github.com/wesnoth/wesnoth/commit/1c29559c8d02bd7ff25f5c0875ee075ec55fb3ae
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-26 (Mon, 26 Apr 2021)

  Changed paths:
    M data/lua/core/map.lua

  Log Message:
  -----------
  Fix bug in wesnoth.map.read_location


Compare: https://github.com/wesnoth/wesnoth/compare/7f731cb31043...1c29559c8d02



More information about the Commits mailing list