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

summaryrefslogtreecommitdiff
path: root/source/game/scripting
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-19 01:16:22 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-19 01:16:22 +1000
commite1645f37fc72e7733b64c51ffbee0370e13cbe29 (patch)
treebdd219080958016e68589476004427cbb50616f5 /source/game/scripting
parent770314fd7e86c0be355f19bd4273ebd12d5bcdc6 (diff)
Support for player entity message commands
Diffstat (limited to 'source/game/scripting')
-rw-r--r--source/game/scripting/StarLuaRoot.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/game/scripting/StarLuaRoot.cpp b/source/game/scripting/StarLuaRoot.cpp
index d41e8fc..5aa0284 100644
--- a/source/game/scripting/StarLuaRoot.cpp
+++ b/source/game/scripting/StarLuaRoot.cpp
@@ -106,6 +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 {
+ String functionName = name ? strf("loadstring: {}", name) : "loadstring";
+ return newContext.engine().createFunctionFromSource(newContext.handleIndex(), source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr());
+ }));
+
for (auto const& scriptPath : scriptPaths)
cache->loadContextScript(newContext, scriptPath);