Fix selection indexes returned from Auto4 Lua macros to be zero-based instead of one-based. Updates #1219.
Originally committed to SVN as r4643.
This commit is contained in:
parent
cac536fc80
commit
816b12cec6
1 changed files with 4 additions and 2 deletions
|
@ -674,7 +674,8 @@ namespace Automation4 {
|
||||||
// leave the new table on top of the stack
|
// leave the new table on top of the stack
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
for (size_t i = 0; i != ints.size(); ++i) {
|
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);
|
lua_rawseti(L, -2, (int)i+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -813,7 +814,8 @@ namespace Automation4 {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
while (lua_next(L, -2)) {
|
while (lua_next(L, -2)) {
|
||||||
if (lua_isnumber(L, -1)) {
|
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);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue