maybe fix /run cmd

This commit is contained in:
yzh 2024-02-14 22:45:59 +08:00
commit eb9564c3de
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();