Function Scripts
Overview
Function scripts are invoked via the 'Lua Script' option of Special Functions configuration page.
Typical uses of Function scripts are:
specialized handling in response to switch position changes
customized announcements
Please be aware that:
all function scripts are stopped if a One-Time Lua script is running
Function scripts DO NOT HAVE ACCESS TO LCD DISPLAY
Lifetime
init
function is called once when the model is selecteddepending on the switch associated with the Special Function, either the
run
function (switch = on) or thebackground
function (switch = off) is called periodicallythe script is stopped and disabled if it misbehaves (e.g. run-time error or low memory)
File Location
Scripts are located on the SD card in the folder /SCRIPTS/FUNCTIONS/<name>.lua. File name length (without extension) must be 6 characters or less (this limit was 8 characters in OpenTX 2.1).
Interface
Every script must include a return
statement at the end, defining its interface to EdgeTX. This statement returns a table with the following fields:
init
function (optional)run
functionbackground
function (optional)
Example
Last updated