| 190 | |
| 191 | template <typename Ret, typename... V> |
| 192 | Maybe<Ret> LuaBaseComponent::invoke(String const& name, V&&... args) { |
| 193 | if (!checkInitialization()) |
| 194 | return {}; |
| 195 | |
| 196 | try { |
| 197 | auto method = m_context->getPath(name); |
| 198 | if (method == LuaNil) |
| 199 | return {}; |
| 200 | return m_context->luaTo<LuaFunction>(std::move(method)).invoke<Ret>(std::forward<V>(args)...); |
| 201 | } catch (LuaException const& e) { |
| 202 | Logger::error("Exception while invoking lua function '{}'. {}", name, outputException(e, true)); |
| 203 | setError(printException(e, false)); |
| 204 | return {}; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | template <typename Ret> |
| 209 | Maybe<LuaValue> LuaBaseComponent::eval(String const& code) { |
no test coverage detected