# OpenTX 2.1 Lua Reference Guide

## OpenTX 2.1 Lua Reference Guide

- [OpenTX 2.1 Lua Reference Guide](https://doc.open-tx.org/opentx-lua-reference-guide/master.md)
- [Introduction](https://doc.open-tx.org/opentx-lua-reference-guide/introduction.md)
- [Acknowledgments](https://doc.open-tx.org/opentx-lua-reference-guide/introduction/acknowledgments.md)
- [Getting Started](https://doc.open-tx.org/opentx-lua-reference-guide/introduction/getting_started.md)
- [Part I - Script Type Overview](https://doc.open-tx.org/opentx-lua-reference-guide/part_i_-_script_type_overview.md)
- [Mix Scripts](https://doc.open-tx.org/opentx-lua-reference-guide/part_i_-_script_type_overview/mix.md)
- [Telemetry Scripts](https://doc.open-tx.org/opentx-lua-reference-guide/part_i_-_script_type_overview/telemetry.md)
- [One-Time Scripts](https://doc.open-tx.org/opentx-lua-reference-guide/part_i_-_script_type_overview/one-time_scripts.md)
- [Wizard Script](https://doc.open-tx.org/opentx-lua-reference-guide/part_i_-_script_type_overview/wizard.md)
- [Function Scripts](https://doc.open-tx.org/opentx-lua-reference-guide/part_i_-_script_type_overview/function_scripts.md)
- [Part II - OpenTX Lua API Programming Guide](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide.md)
- [Input Table Syntax](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/input_table_syntax.md)
- [Output Table Syntax](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/output_table_syntax.md)
- [Init Function Syntax](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/init_function_syntax.md)
- [Run Function Syntax](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/run_function_syntax.md)
- [Return Statement Syntax](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/return_statement_syntax.md)
- [Included Lua Libraries](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries.md)
- [io Library](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io.md)
- [io.open()](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io/io_open.md)
- [io.close()](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io/io_close.md)
- [io.read()](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io/io_read.md)
- [io.write()](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io/io_write.md)
- [io.seek()](https://doc.open-tx.org/opentx-lua-reference-guide/part_ii_-_opentx_lua_api_programming_guide/included_lua_libraries/io/io_seek.md)
- [Part III - OpenTX Lua API Reference](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference.md)
- [Constants](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/constants.md)
- [Key Event Constants](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/constants/key_events.md)
- [General Functions](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions.md)
- [GREY()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/grey.md)
- [defaultChannel(stick)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/defaultchannel.md)
- [defaultStick(channel)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/defaultstick.md)
- [getDateTime()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/getdatetime.md)
- [getFieldInfo(name)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/getfieldinfo.md)
- [getFlightMode(mode)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/getflightmode.md)
- [getGeneralSettings()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/getgeneralsettings.md)
- [getTime()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/gettime.md)
- [getValue(source)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/getvalue.md)
- [getVersion()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/getversion.md)
- [killEvents(key)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/killevents.md)
- [playDuration(duration \[, hourFormat\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/playduration.md)
- [playFile(name)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/playfile.md)
- [playNumber(value, unit \[, attributes\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/playnumber.md)
- [playTone(frequency, duration, pause \[, flags \[, freqIncr\]\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/playtone.md)
- [popupInput(title, event, input, min, max)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/general_functions/popupinput.md)
- [Model Functions](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions.md)
- [model.defaultInputs()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/defaultinputs.md)
- [model.deleteInput(input, line)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/deleteinput.md)
- [model.deleteInputs()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/deleteinputs.md)
- [model.deleteMix(channel, line)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/deletemix.md)
- [model.deleteMixes()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/deletemixes.md)
- [model.getCurve(curve)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getcurve.md)
- [model.getCustomFunction(function)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getcustomfunction.md)
- [model.getGlobalVariable(index \[, flight\_mode\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getglobalvariable.md)
- [model.getInfo()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getinfo.md)
- [model.getInput(input, line)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getinput.md)
- [model.getInputsCount(input)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getinputscount.md)
- [model.getLogicalSwitch(switch)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getlogicalswitch.md)
- [model.getMix(channel, line)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getmix.md)
- [model.getMixesCount(channel)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getmixescount.md)
- [model.getModule(index)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getmodule.md)
- [model.getOutput(index)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/getoutput.md)
- [model.getTimer(timer)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/gettimer.md)
- [model.insertInput(input, line, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/insertinput.md)
- [model.insertMix(channel, line, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/insertmix.md)
- [model.resetTimer(timer)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/resettimer.md)
- [model.setCustomFunction(function, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/setcustomfunction.md)
- [model.setGlobalVariable(index, flight\_mode, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/setglobalvariable.md)
- [model.setInfo(value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/setinfo.md)
- [model.setLogicalSwitch(switch, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/setlogicalswitch.md)
- [model.setModule(index, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/setmodule.md)
- [model.setOutput(index, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/setoutput.md)
- [model.setTimer(timer, value)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/model_functions/settimer.md)
- [Lcd Functions](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions.md)
- [Lcd Functions Overview](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/lcd_functions-overview.md)
- [lcd.clear()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/clear.md)
- [lcd.drawChannel(x, y, source, flags)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawchannel.md)
- [lcd.drawCombobox(x, y, w, list, idx \[, flags\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawcombobox.md)
- [lcd.drawFilledRectangle(x, y, w, h \[, flags\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawfilledrectangle.md)
- [lcd.drawGauge(x, y, w, h, fill, maxfill)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawgauge.md)
- [lcd.drawLine(x1, y1, x2, y2, pattern, flags)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawline.md)
- [lcd.drawNumber(x, y, value \[, flags\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawnumber.md)
- [lcd.drawPixmap(x, y, name)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawpixmap.md)
- [lcd.drawPoint(x, y)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawpoint.md)
- [lcd.drawRectangle(x, y, w, h \[, flags\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawrectangle.md)
- [lcd.drawScreenTitle(title, page, pages)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawscreentitle.md)
- [lcd.drawSource(x, y, source \[, flags\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawsource.md)
- [lcd.drawSwitch(x, y, switch, flags)](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawswitch.md)
- [lcd.drawText(x, y, text \[, flags\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawtext.md)
- [lcd.drawTimer(x, y, value \[, flags\])](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/drawtimer.md)
- [lcd.getLastPos()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/getlastpos.md)
- [lcd.lock()](https://doc.open-tx.org/opentx-lua-reference-guide/part_iii_-_opentx_lua_api_reference/lcd_functions/lock.md)
- [Part IV - Converting OpenTX 2.0 Scripts](https://doc.open-tx.org/opentx-lua-reference-guide/part_iv_-_converting_opentx_20_scripts.md)
- [General Issues](https://doc.open-tx.org/opentx-lua-reference-guide/part_iv_-_converting_opentx_20_scripts/known_issues.md)
- [Handling GPS Sensor data](https://doc.open-tx.org/opentx-lua-reference-guide/part_iv_-_converting_opentx_20_scripts/handling_gps_sensor_data.md)
- [Handling Lipo Sensor Data](https://doc.open-tx.org/opentx-lua-reference-guide/part_iv_-_converting_opentx_20_scripts/handling_lipo_sensor_data.md)
- [Part V - Advanced Topics](https://doc.open-tx.org/opentx-lua-reference-guide/part_v_-_advanced_topics.md)
- [Lua data sharing across scripts](https://doc.open-tx.org/opentx-lua-reference-guide/part_v_-_advanced_topics/lua_data_sharing_across_scripts.md)
- [Debugging techniques](https://doc.open-tx.org/opentx-lua-reference-guide/part_v_-_advanced_topics/debugging_techniques.md)
