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

summaryrefslogtreecommitdiff
path: root/source/game/scripting/StarLuaRoot.cpp
diff options
context:
space:
mode:
authorLumi Kalt <99078103+lumikalt@users.noreply.github.com>2024-02-14 19:32:09 +0000
committerGitHub <noreply@github.com>2024-02-14 19:32:09 +0000
commitf96664b29af6d12a92e309e4be558e45e24015df (patch)
tree2c1166a7175afb2b72983256e7a7e9747f47f8c1 /source/game/scripting/StarLuaRoot.cpp
parent1641c466201e7d8df51b97f0527da58814f04b2d (diff)
parenteb9564c3dedca186f9292bc43a7c1b74990c8d02 (diff)
Merge pull request #17 from yzh5606/main
seems fix the memory issue
Diffstat (limited to 'source/game/scripting/StarLuaRoot.cpp')
-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 c538df1..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();