#####Overview
Function scripts are invoked via the 'Lua Script' option of Special Functions configuration page.
TODO: review all content on this page for accuracy. Documentation for 2.0.x was non-existent, scripts to not appear to get invoked on 2.1.x
- specialized handling in response to switch position changes
- customized announcement of telemetry values
- should not exceed allowed run-time/ number of instructions.
Place them on SD card in folder /SCRIPTS/FUNCTIONS/
- script init function is called
- script run function is periodically called (inside GUI thread, period cca 30ms) until it returns a non-zero result
- script is stopped and disabled if it misbehaves (too long runtime, error in code, low memory)
- all mix scripts are stopped while function script is running
Every mix script must include a return statement at the end, that defines its interface to the rest of OpenTX code. This statement defines:
- script init function (optional, see Init Function Syntax)
- script run function (see Run Function Syntax)
#####Example (interface only):
local function init_func()
end
local function run_func()
end
return { input=input, output=output, run=run_func, init=init_func }
#####Notes:
- init_func() function is called once when script is loaded.
- run_func() function is called periodically until it returns a non-zero result