New Lua function to match WML against a filter

This commit is contained in:
Celtic Minstrel 2016-11-02 00:11:00 -04:00
parent 70b9aea5a4
commit a9dd8da443
2 changed files with 11 additions and 0 deletions

View file

@ -204,6 +204,8 @@ Version 1.13.5+dev:
of the ai.aspects table.
* The location_set iter and stable_iter functions can now be called with no argument.
In this case, they return an iterator suitable for use in a for loop.
* New wesnoth.wml_matches_filter function takes a WML table and a WML filter and tests
if the table matches the filter. The filter syntax is as with [filter_wml].
* Networking
* Ported campaignd to use boost.asio instead of SDL_net.
* Removed unit tests for old networking stack. This was the last part that

View file

@ -244,6 +244,14 @@ static int intf_random(lua_State *L)
}
}
static int intf_wml_matches_filter(lua_State* L)
{
config cfg = luaW_checkconfig(L, 1);
config filter = luaW_checkconfig(L, 2);
lua_pushboolean(L, cfg.matches(filter));
return 1;
}
// End Callback implementations
// Template which allows to push member functions to the lua kernel base into lua as C functions, using a shim
@ -364,6 +372,7 @@ lua_kernel_base::lua_kernel_base()
{ "eval_formula", &lua_formula_bridge::intf_eval_formula},
{ "name_generator", &intf_name_generator },
{ "random", &intf_random },
{ "wml_matches_filter", &intf_wml_matches_filter },
{ nullptr, nullptr }
};