diff --git a/src/lua/LuaTools.cpp b/src/lua/LuaTools.cpp index 68400bf3f..2cd02ce16 100644 --- a/src/lua/LuaTools.cpp +++ b/src/lua/LuaTools.cpp @@ -91,11 +91,14 @@ static int luaPerformWrapper(SimTool *tool, Simulation *sim, Particle *cpart, in lsi->Log(CommandInterface::LogError, "In perform func: " + LuaGetError()); lua_pop(L, 1); } - if (lua_isboolean(L, -1)) + else { - ok = lua_toboolean(L, -1); + if (lua_isboolean(L, -1)) + { + ok = lua_toboolean(L, -1); + } + lua_pop(L, 1); } - lua_pop(L, 1); } return ok; }