Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryzh <yaozihao5606@outlook.com>2024-02-14 22:45:59 +0800
committeryzh <yaozihao5606@outlook.com>2024-02-14 22:45:59 +0800
commiteb9564c3dedca186f9292bc43a7c1b74990c8d02 (patch)
tree2c1166a7175afb2b72983256e7a7e9747f47f8c1
parenta081dbee7b7ac137287330f18f676788e8f86b7a (diff)
parent1d23b7c1be5101c8465d141b56363d4b424d6b91 (diff)
maybe fix /run cmd
-rw-r--r--source/game/scripting/StarLuaRoot.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/source/game/scripting/StarLuaRoot.cpp b/source/game/scripting/StarLuaRoot.cpp
index fc205c0..d79e8f4 100644
--- a/source/game/scripting/StarLuaRoot.cpp
+++ b/source/game/scripting/StarLuaRoot.cpp
@@ -106,9 +106,11 @@ LuaContext LuaRoot::createContext(StringList const& scriptPaths) {
}
});
- newContext.set("loadstring", m_luaEngine->createFunction([&newContext](String const& source, Maybe<String> const& name, Maybe<LuaValue> const& env) -> LuaFunction {
+ auto handleIndex = newContext.handleIndex();
+ auto engine = m_luaEngine.get();
+ newContext.set("loadstring", m_luaEngine->createFunction([engine,handleIndex](String const& source, Maybe<String> const& name, Maybe<LuaValue> const& env) -> LuaFunction {
String functionName = name ? strf("loadstring: {}", *name) : "loadstring";
- return newContext.engine().createFunctionFromSource(newContext.handleIndex(), source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr());
+ return engine->createFunctionFromSource(handleIndex, source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr());
}));
auto assets = Root::singleton().assets();