Skip to content

Commit

Permalink
Hotfix for hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegmd committed Feb 17, 2021
1 parent 2fb6047 commit e8c8cac
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/scripting/ScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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);
}};

Expand Down

0 comments on commit e8c8cac

Please sign in to comment.