diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index 725f6e14a2..f1f2e79754 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -85,7 +85,7 @@ private: bool registerLuaLibrary(lua_State* state, const LuaLibrary& library); void addLibraryFunctions(lua_State* state, const LuaLibrary& library, bool replace); - bool isLibraryNameAllowed(const std::string& name); + bool isLibraryNameAllowed(lua_State* state, const std::string& name); void addBaseLibrary(); void remapPrintFunction(); diff --git a/scripts/default_startup.lua b/scripts/default_startup.lua index a05b6665e3..cb97c25408 100644 --- a/scripts/default_startup.lua +++ b/scripts/default_startup.lua @@ -10,7 +10,7 @@ openspace.time.setTime("2007 FEB 27 16:40:00") -- This is the start tim openspace.time.setDeltaTime(10) -- How many seconds pass per second of realtime, changeable in the GUI -dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))() -- Load the default keybindings +dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) -- Load the default keybindings -- openspace.time.setDeltaTime(50); diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index 5ba590cfd4..771b00670a 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -324,17 +324,16 @@ bool ScriptEngine::hasLibrary(const std::string& name) //return false; } -bool ScriptEngine::isLibraryNameAllowed(const std::string& name) -{ +bool ScriptEngine::isLibraryNameAllowed(lua_State* state, const std::string& name) { bool result = false; - lua_getglobal(_state, _openspaceLibraryName.c_str()); - const bool hasOpenSpaceLibrary = lua_istable(_state, -1); + lua_getglobal(state, _openspaceLibraryName.c_str()); + const bool hasOpenSpaceLibrary = lua_istable(state, -1); if (!hasOpenSpaceLibrary) { LFATAL("OpenSpace library was not created in initialize method"); return false; } - lua_getfield(_state, -1, name.c_str()); - const int type = lua_type(_state, -1); + lua_getfield(state, -1, name.c_str()); + const int type = lua_type(state, -1); switch (type) { case LUA_TNONE: case LUA_TNIL: @@ -370,7 +369,7 @@ bool ScriptEngine::isLibraryNameAllowed(const std::string& name) break; } - lua_pop(_state, 2); + lua_pop(state, 2); return result; } @@ -496,7 +495,7 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, const LuaLibrary& librar //ghoul::lua::logStack(_state); } else { - const bool allowed = isLibraryNameAllowed(library.name); + const bool allowed = isLibraryNameAllowed(state, library.name); if (!allowed) return false;