maybe fix the /run cmd

This commit is contained in:
yzh 2024-02-14 22:39:35 +08:00
parent 29dcec6afe
commit 1d23b7c1be
No known key found for this signature in database
GPG Key ID: 42F9CE5DC67BB975

View File

@ -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"; 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(); auto assets = Root::singleton().assets();