- The Lua interpreter will trigger an error if there is a mistake in the program, check the rusEFI console to see errors and script output.
- All `index` parameters start with the first element at index at 0.
## Writing Your Script
The entire Lua script is read at startup, then a function called `onTick` is called periodically by rusEFI.
Here is a simple script you can run to illustrate this behavior:
```
print('Hello Lua startup!')
function onTick()
print('Hello onTick()')
end
```
### Controlling the Tick Rate
The function `setTickRate(hz)` can be used to configure how often rusEFI calls the `onTick` function. If your script does a lot of work in the `onTick()` function it may run slower than the desired rate.
-`tableIdx`: Index of the table to use. Currently 4 tables are supported, so indices 0, 1, 2, and 3 are valid.
-`x`: X-axis value to look up in the table (this is often RPM)
-`y`: Y-axis value to look up in the table (this is often load)
- Returns
- A number representing the value looked up from the table.
## Input
### `getSensor(index)`
Reads the specified sensor.
- Parameters
-`index`: Index of the sensor to read. [A list of sensor indices can be found here.](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/sensors/sensor_type.h)
- Returns
- A reading from the sensor, or `nil` if the sensor has a problem or isn't configured.
### `getSensorRaw(index)`
Reads the raw value from the specified sensor. For most sensors, this means the analog voltage on the relevant input pin.
- Parameters
-`index`: Index of the sensor to read. [A list of sensor indices can be found here.](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/sensors/sensor_type.h)
- Returns
- The raw value that yielded the sensor reading, or 0 if the sensor doesn't support raw readings, isn't configured, or has failed.
Checks whether a particular sensor is configured (whether it is currently valid or not).
- Parameters
-`index`: Index of the sensor to check. [A list of sensor indices can be found here.](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/sensors/sensor_type.h)
- Returns
- A boolean value, `true` if the sensor is configured, and `false` if not.