mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
Fixes #6029
This commit is contained in:
parent
d983138f77
commit
6684a75d92
1 changed files with 9 additions and 5 deletions
|
@ -636,18 +636,22 @@ bool luaLoadMixScript(uint8_t index)
|
|||
|
||||
bool luaLoadFunctionScript(uint8_t index, uint8_t ref)
|
||||
{
|
||||
if (ref >= SCRIPT_GFUNC_FIRST && g_model.noGlobalFunctions)
|
||||
return false;
|
||||
CustomFunctionData * fn;
|
||||
|
||||
CustomFunctionData & fn = (ref < SCRIPT_GFUNC_FIRST ? g_model.customFn[index] : g_eeGeneral.customFn[index]);
|
||||
if (ref < SCRIPT_GFUNC_FIRST)
|
||||
fn = &g_model.customFn[index];
|
||||
else if (!g_model.noGlobalFunctions)
|
||||
fn = &g_eeGeneral.customFn[index];
|
||||
else
|
||||
return true;
|
||||
|
||||
if (fn.func == FUNC_PLAY_SCRIPT && ZEXIST(fn.play.name)) {
|
||||
if (fn->func == FUNC_PLAY_SCRIPT && ZEXIST(fn->play.name)) {
|
||||
if (luaScriptsCount < MAX_SCRIPTS) {
|
||||
ScriptInternalData & sid = scriptInternalData[luaScriptsCount++];
|
||||
sid.reference = ref + index;
|
||||
sid.state = SCRIPT_NOFILE;
|
||||
char filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME + sizeof(SCRIPT_EXT)] = SCRIPTS_FUNCS_PATH "/";
|
||||
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn.play.name, LEN_FUNCTION_NAME);
|
||||
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn->play.name, LEN_FUNCTION_NAME);
|
||||
filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME] = '\0';
|
||||
strcat(filename + sizeof(SCRIPTS_FUNCS_PATH), SCRIPT_EXT);
|
||||
if (luaLoad(lsScripts, filename, sid) == SCRIPT_PANIC) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue