From 97deeeb4d3d96711a76459bcbcb5d256a649b7bf Mon Sep 17 00:00:00 2001 From: alteman Date: Tue, 20 Jun 2023 12:03:33 +0300 Subject: [PATCH] fix(lua): Support changing module type from model.setModule() (#3699) --- radio/src/lua/api_model.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/radio/src/lua/api_model.cpp b/radio/src/lua/api_model.cpp index 8a5ee7a26..8d41128f4 100644 --- a/radio/src/lua/api_model.cpp +++ b/radio/src/lua/api_model.cpp @@ -226,7 +226,13 @@ static int luaModelSetModule(lua_State *L) for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { luaL_checktype(L, -2, LUA_TSTRING); // key is string const char * key = luaL_checkstring(L, -2); - if (!strcmp(key, "subType")) { + if (!strcmp(key, "Type")) { + uint8_t newtype = luaL_checkinteger(L, -1); + if (newtype != module.type) { + setModuleType(idx, newtype); + } + } + else if (!strcmp(key, "subType")) { module.subType = luaL_checkinteger(L, -1); } else if (!strcmp(key, "modelId")) {