From 5e31638b92c1d3d8c4f85eafaf3cddc9db2f57ea Mon Sep 17 00:00:00 2001 From: Erik Broberg Date: Tue, 30 Aug 2016 14:01:42 -0400 Subject: [PATCH] Enable the global Lua state when loading scheduled scripts from file --- include/openspace/scripting/scriptscheduler.h | 2 +- src/scripting/scriptscheduler.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/openspace/scripting/scriptscheduler.h b/include/openspace/scripting/scriptscheduler.h index e0783d7c27..320bbac0a7 100644 --- a/include/openspace/scripting/scriptscheduler.h +++ b/include/openspace/scripting/scriptscheduler.h @@ -58,7 +58,7 @@ struct ScheduledScript { class ScriptScheduler { public: - void loadScripts(const std::string& filename); + void loadScripts(const std::string& filename, lua_State* L = nullptr); void loadScripts(const ghoul::Dictionary& dict); void skipTo(double time); diff --git a/src/scripting/scriptscheduler.cpp b/src/scripting/scriptscheduler.cpp index fa2bd0d03b..50ab2c1fd9 100644 --- a/src/scripting/scriptscheduler.cpp +++ b/src/scripting/scriptscheduler.cpp @@ -63,10 +63,10 @@ ScheduledScript::ScheduledScript(const ghoul::Dictionary& dict) } } -void ScriptScheduler::loadScripts(const std::string& filepath) { +void ScriptScheduler::loadScripts(const std::string& filepath, lua_State* L) { ghoul::Dictionary timedScriptsDict; try { - ghoul::lua::loadDictionaryFromFile(absPath(filepath), timedScriptsDict); + ghoul::lua::loadDictionaryFromFile(absPath(filepath), timedScriptsDict, L); } catch (const ghoul::RuntimeError& e) { LERROR(e.what()); @@ -145,7 +145,7 @@ namespace luascriptfunctions { return luaL_error(L, "filepath string is empty"); } - OsEng.scriptScheduler().loadScripts(missionFileName); + OsEng.scriptScheduler().loadScripts(missionFileName, L); } int skipTo(lua_State* L) {