diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index 91f6314c9..f77dc4c7e 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -674,7 +674,8 @@ namespace Automation4 { // leave the new table on top of the stack lua_newtable(L); for (size_t i = 0; i != ints.size(); ++i) { - lua_pushinteger(L, ints[i]+1); + // We use zero-based indexing but Lua wants one-based, so add one + lua_pushinteger(L, ints[i] + 1); lua_rawseti(L, -2, (int)i+1); } } @@ -813,7 +814,8 @@ namespace Automation4 { lua_pushnil(L); while (lua_next(L, -2)) { if (lua_isnumber(L, -1)) { - selected.push_back(lua_tointeger(L, -1)); + // Lua uses one-based indexing but we want zero-based, so subtract one + selected.push_back(lua_tointeger(L, -1) - 1); } lua_pop(L, 1); }