From cdda903a25be34c0942025591729b959c0656d10 Mon Sep 17 00:00:00 2001 From: Jesper Frickmann Date: Wed, 23 Mar 2022 05:09:43 -0400 Subject: [PATCH] fix: Lua - Changed getSwitch* so can also get "One" and "ON" switch positions (#1720) Use `ModelCustomFunctionsContext` instead of `LogicalSwitchesContext` to get "One" and "ON" switch positions --- radio/src/lua/api_general.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 7476550f8..25c167ecc 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -2169,7 +2169,7 @@ static int luaGetSwitchIndex(lua_State * L) } for (idx = SWSRC_NONE; idx < SWSRC_COUNT; idx++) { - if (isSwitchAvailableInLogicalSwitches(idx)) { + if (isSwitchAvailable(idx, ModelCustomFunctionsContext)) { char* s = getSwitchPositionName(idx); if (!strncasecmp(s, name, 31)) { found = true; @@ -2203,7 +2203,7 @@ static int luaGetSwitchIndex(lua_State * L) static int luaGetSwitchName(lua_State * L) { swsrc_t idx = luaL_checkinteger(L, 1); - if (idx > -SWSRC_COUNT && idx < SWSRC_COUNT && isSwitchAvailableInLogicalSwitches(idx)) { + if (idx > -SWSRC_COUNT && idx < SWSRC_COUNT && isSwitchAvailable(idx, ModelCustomFunctionsContext)) { char* name = getSwitchPositionName(idx); lua_pushstring(L, name); } @@ -2226,7 +2226,7 @@ static int luaGetSwitchName(lua_State * L) static int luaGetSwitchValue(lua_State * L) { swsrc_t idx = luaL_checkinteger(L, 1); - if (idx > -SWSRC_COUNT && idx < SWSRC_COUNT && isSwitchAvailableInLogicalSwitches(idx)) + if (idx > -SWSRC_COUNT && idx < SWSRC_COUNT && isSwitchAvailable(idx, ModelCustomFunctionsContext)) lua_pushboolean(L, getSwitch(idx)); else lua_pushnil(L); @@ -2251,7 +2251,7 @@ static int luaNextSwitch(lua_State * L) swsrc_t idx = luaL_checkinteger(L, 2); while (++idx <= last) { - if (isSwitchAvailableInLogicalSwitches(idx)) { + if (isSwitchAvailable(idx, ModelCustomFunctionsContext)) { char* name = getSwitchPositionName(idx); lua_pushinteger(L, idx); lua_pushstring(L, name);