Device, timing, remapper, and BVAR built-ins
These functions affect VM timing, active slots, device settings, LEDs, or persistent binary-variable storage. Treat slot changes and persistent writes as deliberate user actions, never background work at the base of main.
get_rtime
Returns the elapsed time between the current and previous main iterations.
Syntax
elapsed_ms = get_rtime();Parameters
None.
Returns
Elapsed milliseconds. The usual value is near the VM interval, but it can change with timing control and runtime conditions.
Example
int elapsed_ms;
main {
elapsed_ms = elapsed_ms + get_rtime();
if(elapsed_ms >= 1000) elapsed_ms = elapsed_ms - 1000;
set_val(TRACE_1, elapsed_ms);
}Subtract the threshold instead of resetting to zero when accumulated timing should retain overshoot.
get_slot
Returns the currently active Zen memory slot.
Syntax
Parameters
None.
Returns
The active slot number.
Example
Refresh the cached value only when the script design has a reason to expect a slot-state change.
load_slot
Immediately attempts to load a slot. Slot 0 unloads the current programmed slot; the accepted range is 0..8.
Syntax
Parameters
slot:0..8.
Returns
Nothing. Loading occurs immediately, so code after the call must not be relied on.
Example
Use an intentional chord to prevent accidental slot changes.
get_ctrlbutton
Returns the configured remote slot-control button mode from the Zen device settings.
Syntax
Parameters
None.
Returns
The configured control-button mode; the supplied Live documentation identifies values 0, 1, and 8.
Example
Treat the result as device configuration data, not as a controller report identifier.
vm_tctrl
Applies an offset to the VM interval for the next iteration.
Syntax
Parameters
timeout_offset: compiler-accepted range-9..30relative to the normal interval.
Returns
Nothing.
Example
Shorter intervals increase VM work and may reduce stability. Measure VM load and controller behavior before keeping a non-default value.
set_rgb
Sets the Zen or controller LED color with red, green, and blue components.
Syntax
Parameters
red,green,blue: each0..255.
Returns
Nothing.
Example
Render on a state change instead of rewriting the same color every cycle.
set_hsb
Sets the Zen or controller LED color using hue, saturation, and brightness.
Syntax
Parameters
hue:0..360degrees.saturation:0..100percent.brightness:0..100percent.
Returns
Nothing.
Example
get_info
Queries a value from the active mouse-and-keyboard profile or related Live device state.
Syntax
Parameters
selector: numeric selector accepted by the exact Live build.
Returns
The selected information value.
Example
Use the documented Zen Studio Live selector constants whenever possible. Confirm any raw numeric selector against the intended Live build before relying on its meaning.
set_remapper
Changes one entry in the device-level remapper. This is different from a script remap declaration because it modifies device configuration.
Syntax
Parameters
identifier_from:BUTTON_MIN..BUTTON_MAX.identifier_to:BUTTON_MIN..BUTTON_MAX.
Returns
Nothing.
Example
Use a guarded, explicit action. A device remapper change can affect scripts beyond the current slot.
save_eeprom
Persists changed device settings to EEPROM.
Syntax
Parameters
None.
Returns
Nothing.
Example
get_bvar
Reads one indexed BVAR value on the 32-bit target.
Syntax
Parameters
index:0..1023.
Returns
The value stored at the selected index.
Example
Validate loaded data before using it, and reserve index ranges so unrelated records cannot overlap.
set_bvar
Writes one indexed BVAR value on the 32-bit target.
Syntax
Parameters
index:0..1023.value: current-target signed integer expression. Device-test storage width and signed round trips for the intended firmware.
Returns
Nothing.
Example
Use named schema constants, bounds-check computed indexes, and write only on an explicit save/change event.
Last updated

