Output Functions
Output functions change what the script sends onward for the current tick. Use them after reading input and deciding what the controller output should be.
Quick Reference
| Function | Signature | Returns | Use |
|---|---|---|---|
set_val |
int set_val(int id, int value) |
1 on success, 0 on invalid input |
Set a button, trigger, stick, or supported axis output |
set_val |
int set_val(int id, fix32 value) |
1 on success, 0 on invalid input |
Set analog output using fixed-point math |
inhibit |
int inhibit(int id, int ms) |
1 on success, 0 on invalid input |
Temporarily zero physical input for one control |
swap |
int swap(int first, int second) |
Status value | Exchange two current controller values |
block_all_inputs |
int block_all_inputs() |
0 |
Zero every controller output for the current tick |
set_val
int set_val(int id, int value);
int set_val(int id, fix32 value);Sets the current output value for a controller identifier. The id should be one of the constants from the Constants page, such as BUTTON_5 or STICK_1_X.
Parameters
| Parameter | Type | Description |
|---|---|---|
id |
int |
Controller identifier to write |
value |
int or fix32 |
Output value for the current tick |
Value Ranges
| Output kind | Typical value range |
|---|---|
| Digital button | 0 or 100 |
| Analog trigger | 0 to 100 |
| Stick axis | -100 to 100 |
Behavior
set_val() affects the script-facing output for this tick. Later set_val() calls for the same id overwrite earlier calls in the same tick.
main {
set_val(BUTTON_16, 100); // Press the bottom face button.
set_val(STICK_1_X, 35.0); // Move right stick to the right.
set_val(STICK_1_Y, -20.0); // Move right stick upward/downward depending on host axis convention.
}Analog Math
Use fix32 when scaling or smoothing analog values. Clamp the result before writing it so output stays inside the expected range.
fix32 sensitivity = 1.25;
main {
fix32 x = get_val(STICK_1_X) * sensitivity;
fix32 y = get_val(STICK_1_Y) * sensitivity;
set_val(STICK_1_X, clamp(x, -100.0, 100.0));
set_val(STICK_1_Y, clamp(y, -100.0, 100.0));
}Button Remap
When remapping, copy the source value first, then clear or replace the original output.
main {
fix32 bottom_face = get_val(BUTTON_16);
set_val(BUTTON_15, bottom_face);
set_val(BUTTON_16, 0);
}Threshold-to-Digital Conversion
Convert an analog control to a digital-style output after it crosses a chosen accessibility threshold:
main {
if (get_val(BUTTON_5) > 5) {
set_val(BUTTON_5, 100);
}
}inhibit
int inhibit(int id, int ms);Temporarily zeroes the selected physical input. An explicit set_val() made by the script can still write that output while the inhibit period is active.
Inhibit Parameters
| Parameter | Type | Description |
|---|---|---|
id |
int |
Controller identifier to block |
ms |
int |
Duration in milliseconds |
main {
if (event_active(BUTTON_16)) {
inhibit(BUTTON_5, 200);
}
}block(id, ms) is a compatibility alias for inhibit(id, ms).
swap and blockallinputs
int swap(int first, int second);
int block_all_inputs();swap() exchanges the current values of two controller identifiers. block_all_inputs() clears every controller output for the current tick; call it from main while a menu or mode should suppress controller input.
main {
if (get_val(BUTTON_4)) {
block_all_inputs();
} else {
swap(BUTTON_16, BUTTON_16);
}
}Interaction With Input Reads
get_val() reads the current script-facing value. If your script already changed an identifier with set_val(), later get_val() calls in the same tick can reflect that script-facing change.
Use get_actual() when you need the physical/translated input view regardless of output changes made by the script.
main {
if (get_actual(BUTTON_5) > 0) {
printf("Physical trigger is down");
}
set_val(BUTTON_5, 0);
}Notes
- Use named constants instead of raw numeric IDs for readable scripts.
- Clamp stick and trigger math before writing output.
- Write output in
mainfor continuous behavior and insidecomboblocks for timed sequences. - If multiple features write the same output, put the highest-priority write last.