From e8c8cace1b9d95c95c76f4127b54b8178e7166c5 Mon Sep 17 00:00:00 2001 From: yamashi Date: Wed, 17 Feb 2021 20:45:56 +0100 Subject: [PATCH] Hotfix for hotkeys --- src/scripting/ScriptContext.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/scripting/ScriptContext.cpp b/src/scripting/ScriptContext.cpp index f5bd6aef..e81ac909 100644 --- a/src/scripting/ScriptContext.cpp +++ b/src/scripting/ScriptContext.cpp @@ -57,7 +57,7 @@ ScriptContext::ScriptContext(LuaSandbox& aLuaSandbox, const std::filesystem::pat m_logger->error("Tried to register an unknown event '{}'!", acName); }; - env["registerHotkey"] = [this](const std::string& acID, const std::string& acDescription, sol::function aCallback) + env["registerHotkey"] = [this, &env](const std::string& acID, const std::string& acDescription, sol::function aCallback) { if (acID.empty() || (std::find_if(acID.cbegin(), acID.cend(), [](char c){ return !(isalpha(c) || isdigit(c) || c == '_'); }) != acID.cend())) @@ -74,11 +74,8 @@ ScriptContext::ScriptContext(LuaSandbox& aLuaSandbox, const std::filesystem::pat auto loggerRef = m_logger; std::string vkBindID = m_name + '.' + acID; - VKBind vkBind = { vkBindID, acDescription, [loggerRef, aCallback, this]() + VKBind vkBind = { vkBindID, acDescription, [loggerRef, aCallback, &env]() { - auto& sb = m_sandbox[m_sandboxID]; - auto& env = sb.GetEnvironment(); - TryLuaFunction(loggerRef, env, aCallback); }};