Function Scripts
Last updated
Last updated
Function scripts are invoked via the 'Lua Script' option of Special Functions configuration page.
specialized handling in response to switch position changes
customized announcements
should not exceed allowed run-time/ number of instructions.
all function scripts are stopped while one-time script is running (see Lua One-time scripts)
Function scripts DO NOT HAVE ACCESS TO LCD DISPLAY
Place them on SD card in folder /SCRIPTS/FUNCTIONS/
script init function is called once when model is loaded
script run function is periodically called as long as switch condition is true
script is stopped and disabled if it misbehaves (too long runtime, error in code, low memory)
Every 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)
local variables retain their values for as long as the model is loaded regardless of switch condition value
The script below is an example of customized countdown announcements. Note that the init function determines which version of OpenTX is running and sets the unit parameter for playNumber() accordingly.