diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 07028156eff..aee0aee505d 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -631,8 +631,12 @@ static bool luaLoadFunctionScript(uint8_t ref) CustomFunctionData * fn; if (ref <= SCRIPT_FUNC_LAST) { - idx = ref - SCRIPT_FUNC_FIRST; - fn = &g_model.customFn[idx]; + if (modelSFEnabled()) { + idx = ref - SCRIPT_FUNC_FIRST; + fn = &g_model.customFn[idx]; + } else { + return false; + } } else if (radioGFEnabled()) { idx = ref - SCRIPT_GFUNC_FIRST; @@ -1101,10 +1105,12 @@ static bool resumeLua(bool init, bool allowLcdUsage) CustomFunctionsContext * functionsContext; if (ref <= SCRIPT_FUNC_LAST) { + if (!modelSFEnabled()) continue; idx = ref - SCRIPT_FUNC_FIRST; fn = &g_model.customFn[idx]; functionsContext = &modelFunctionsContext; } else { + if (!radioGFEnabled()) continue; idx = ref - SCRIPT_GFUNC_FIRST; fn = &g_eeGeneral.customFn[idx]; functionsContext = &globalFunctionsContext; diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index 2cb608e86b6..95446962f43 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -1079,7 +1079,11 @@ void evalMixes(uint8_t tick10ms) } else { globalFunctionsContext.reset(); } - evalFunctions(g_model.customFn, modelFunctionsContext); + if (modelSFEnabled()) { + evalFunctions(g_model.customFn, modelFunctionsContext); + } else { + modelFunctionsContext.reset(); + } } //========== LIMITS ===============