diff --git a/src/controllers/plugins/LuaUtilities.hpp b/src/controllers/plugins/LuaUtilities.hpp index e0ce845d4..817b11386 100644 --- a/src/controllers/plugins/LuaUtilities.hpp +++ b/src/controllers/plugins/LuaUtilities.hpp @@ -146,7 +146,11 @@ bool pop(lua_State *L, T *out, StackIdx idx = -1) auto ok = peek(L, out, idx); if (ok) { - lua_pop(L, 1); + if (idx < 0) + { + idx = lua_gettop(L) + idx; + } + lua_remove(L, idx); } return ok; }