# Run Function Syntax

The run function is the function that is periodically called for the lifetime of script execution. Syntax of the run function is different between [mix scripts](https://luadoc.edgetx.org/opentx_2.3/part_i_-_script_type_overview/mix) and [telemetry scripts](https://luadoc.edgetx.org/opentx_2.3/part_i_-_script_type_overview/telemetry).

## Run Function for Mix Scripts

```lua
local function <run_function_name>([first input, [second input], …])

   -- if mix has no return values
   return

   -- if mix has two return values
   return value1, value2

end
```

* **Input parameters:**

  zero or more input values, their names are arbitrary, their meaning and order is defined by the input table. (see [Input Table Syntax](https://luadoc.edgetx.org/opentx_2.3/part_ii_-_opentx_lua_api_programming_guide/input_table_syntax))
* **Return values:**
  * none - if output table is empty (i.e. script has no output)

    values

    * or -
  * comma separated list of output values, their order and meaning is defined by the output table. (see [Output Table Syntax](https://luadoc.edgetx.org/opentx_2.3/part_ii_-_opentx_lua_api_programming_guide/output_table_syntax))

## Run Function for Telemetry Scripts

```lua
local function <run_function_name>(key-event)
  return 0 -- values other than zero will halt the script
end
```

* **Input parameters:**

  The *key-event* parameter indicates which transmitter button has been pressed (see [Key Events](https://luadoc.edgetx.org/opentx_2.3/part_iii_-_opentx_lua_api_reference/constants/key_events))
* **Return values:**

  A non-zero return value will halt the script


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://luadoc.edgetx.org/opentx_2.3/part_ii_-_opentx_lua_api_programming_guide/run_function_syntax.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
