Parameters:
"output" (integer): Script output number, 1 - 10.
"state" (boolean): true = on (100% duty), false = off (0% duty).
Returns: Nothing.
Lua code:
io.set(1, true) -- turn on output 1
io.set(1, false) -- turn off output 1
io.set(3, rpm > 5000) -- conditional: on if RPM > 5000
The actual physical output pin for each script output number is configured in MTune under the output assignment settings, see Output Functions.
Parameters:
"output" (integer): Script output number, 1-10.
"duty" (number): Duty cycle in percent, 0.0 - 100.0`. Resolution: 0.1%. Clamped to range.
"frequency" (integer): (Optional) PWM frequency in Hz, 10 - 20000. Default: 100Hz. Clamped to range.
Returns: Nothing.
Lua code:
io.pwm(1, 50.0) - 50% duty at 100 Hz (default)
io.pwm(2, 75.5, 1000) - 75.5% duty at 1 kHz
io.pwm(3, 0) - 0% (effectively off)
io.pwm(4, 100, 20000) - 100% at 20 kHz
The actual ECU function triggered by each slot (e.g., "AC request", "Nitrous arm", "Flat shift") is configured in MTune.
Parameters:
"din_number" (integer): script DIN function slot, 1-12.
"state" (boolean): true = active (on), false = inactive (off).
Returns: Nothing.
Lua code:
io.din(1, true) - activate DIN function slot 1
io.din(1, false) - deactivate DIN function slot 1
See Script Input Control.
The actual ECU sensor function assigned to each slot (e.g.,"Oil pressure", "Fuel level") is configured in MTune.
Parameters:
"ain_number" (integer): Script AIN function slot, 1-12.
"value" (integer or float): The sensor value. Integers are stored as-is (the AIN system uses 0.1 scaling, so raw 1234 = 123.4 in scaled units). Floats are automatically multiplied by 10 and rounded.
Returns: Nothing.
Lua code:
-- Pass a raw integer (985 = 98.5 in scaled units)
io.ain(1, 985)
-- Pass a float (automatically scaled: 98.5 → raw 985)
io.ain(2, 98.5)
Note: AIN values must be refreshed at least every 100 ms or they will revert to their default input. Always call io.ain() from within a loop that runs frequently enough.
For more information about the MaxxECU user scripts, see User Scripts (LUA), or directly reference the LUA api reference and LUA examples. For more all available LUA settings and options, see Script Code, Script Input Control, Output Functions and Script RT values.