diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-09-04 16:25:43 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-09-04 16:25:43 -0400 |
commit | d72ddddcaf07a1b9c7fb479e2432cf1bfa286a94 (patch) | |
tree | e86fe98bc9c46b4915d24684b07b7a8721465d6c /indra/newview/llluamanager.cpp | |
parent | a980a8f30870d35a5a45cbf52169f7bf35cf95ce (diff) | |
parent | 487973d3f0ee9b8583b3d977ca6a405cba5fe518 (diff) |
Merge branch 'release/luau-scripting' into lua-merge
Diffstat (limited to 'indra/newview/llluamanager.cpp')
-rw-r--r-- | indra/newview/llluamanager.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp index 41b1cd55b7..91a34345be 100644 --- a/indra/newview/llluamanager.cpp +++ b/indra/newview/llluamanager.cpp @@ -49,6 +49,8 @@ #include <string_view> #include <vector> +S32 LLLUAmanager::sAutorunScriptCount = 0; +S32 LLLUAmanager::sScriptCount = 0; std::map<std::string, std::string> LLLUAmanager::sScriptNames; lua_function(sleep, "sleep(seconds): pause the running coroutine") @@ -172,7 +174,7 @@ LLLUAmanager::startScriptFile(const std::string& filename) // Despite returning from startScriptFile(), we need this Promise to // remain alive until the callback has fired. auto promise{ std::make_shared<LLCoros::Promise<script_result>>() }; - runScriptFile(filename, + runScriptFile(filename, false, [promise](int count, LLSD result) { promise->set_value({ count, result }); }); return LLCoros::getFuture(*promise); @@ -183,11 +185,11 @@ LLLUAmanager::script_result LLLUAmanager::waitScriptFile(const std::string& file return startScriptFile(filename).get(); } -void LLLUAmanager::runScriptFile(const std::string &filename, script_result_fn result_cb, - script_finished_fn finished_cb) +void LLLUAmanager::runScriptFile(const std::string &filename, bool autorun, + script_result_fn result_cb, script_finished_fn finished_cb) { // A script_result_fn will be called when LuaState::expr() completes. - LLCoros::instance().launch(filename, [filename, result_cb, finished_cb]() + LLCoros::instance().launch(filename, [filename, autorun, result_cb, finished_cb]() { ScriptObserver observer(LLCoros::getName(), filename); llifstream in_file; @@ -195,6 +197,12 @@ void LLLUAmanager::runScriptFile(const std::string &filename, script_result_fn r if (in_file.is_open()) { + if (autorun) + { + sAutorunScriptCount++; + } + sScriptCount++; + // A script_finished_fn is used to initialize the LuaState. // It will be called when the LuaState is destroyed. LuaState L(finished_cb); |