diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index f101760c6..498d06992 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -1748,16 +1748,17 @@ void luaError(uint8_t error) void luaExec(const char *filename) { luaInit(); - - standaloneScript.state = SCRIPT_NOFILE; - int result = luaLoad(filename, standaloneScript); - // TODO the same with run ... - if (result == SCRIPT_OK) { - luaState = INTERPRETER_RUNNING_STANDALONE_SCRIPT; - } - else { - luaError(result); - luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS; + if (L) { + standaloneScript.state = SCRIPT_NOFILE; + int result = luaLoad(filename, standaloneScript); + // TODO the same with run ... + if (result == SCRIPT_OK) { + luaState = INTERPRETER_RUNNING_STANDALONE_SCRIPT; + } + else { + luaError(result); + luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS; + } } } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index a1a8616e6..d70988264 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1500,12 +1500,9 @@ enum AUDIO_SOUNDS { uint8_t outputsCount; ScriptOutput outputs[MAX_SCRIPT_OUTPUTS]; }; - enum InterpreterState { - INTERPRETER_RUNNING_PERMANENT_SCRIPTS, - INTERPRETER_RUNNING_STANDALONE_SCRIPT, - INTERPRETER_RELOAD_PERMANENT_SCRIPTS, - INTERPRETER_PANIC, - }; + #define INTERPRETER_RUNNING_STANDALONE_SCRIPT 1 + #define INTERPRETER_RELOAD_PERMANENT_SCRIPTS 2 + #define INTERPRETER_PANIC 255 extern uint8_t luaState; extern uint8_t luaScriptsCount; extern ScriptInternalData standaloneScript;