From fb6031d6a14c868914a91afd14fcd43c41faf9eb Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Thu, 31 Mar 2016 02:12:53 -0400 Subject: [PATCH] lua_function= in SUF now has limited support for non-global functions To be precise, the string is considered as a dot-separated list of components. --- changelog | 2 ++ src/scripting/game_lua_kernel.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 8ea39cd7ef6e..efadb73f5940 100644 --- a/changelog +++ b/changelog @@ -21,6 +21,8 @@ Version 1.13.4+dev: * Weapon filters now support number, parry, accuracy, and movement_used * New [has_attack] in standard unit filters; supercedes has_weapon= and uses full weapon filter. + * lua_function=var.member now works in SUF; however, 'var' still needs to + be a global variable. * AiWML: * Simplified aspect syntax which works for all aspects, present and future: * All aspects with simple values can be specified as key=value diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index a1bf10df12b7..686b2ed6c19a 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -4896,7 +4896,8 @@ bool game_lua_kernel::run_filter(char const *name, unit const &u) if (!ui.valid()) return false; // Get the user filter by name. - if(!luaW_getglobal(L, name)) + const std::vector& path = utils::split(name, '.', utils::STRIP_SPACES); + if(!luaW_getglobal(L, path)) { std::string message = std::string() + "function " + name + " not found"; log_error(message.c_str(), "Lua SUF Error");