Embedded Sequence Reference
A reference for the keywords and functions available in Synnax's embedded sequence editor.
Reading Channel Values
Reading channel values is as simple as typing the name of the channel you wish to read
as a variable. For example, if we have a channel called my_channel
, we can read its
value as follows:
if my_channel > 100 then
end
During each sequence step, the value of my_channel
will be updated with the latest
value from the channel.
Writing Channel Values
Writing to a channel can be done by calling the set
function with the channel name and
value. For example, if we have a channel called my_channel
, we can write to it as
follows:
set("my_channel", 100)
The sequence editor’s auto-complete will make sure to add the channel to the “Write To” list of channels for the sequence. Make sure every channel you’d like to write to is in the list by checking the dialog at the bottom of the editor.
Control Authority
The embedded sequence editor allows you to set the control authority of a channel at arbitrary points in the sequence. This is particularly useful for abort sequences where you’ll need to seize control of a set of channels from one or more separate sequences.
To set the control authority of a channel, use the set_authority
function with the
channel name and the desired authority. For example, if we have a channel called
my_channel
, we can set its authority to 100 as follows:
set_authority("my_channel", 100)
Here’s a basic example of an abort sequence that seizes control of a set of channels from two separate sequences:
-- take absolute control of the channel
if pressure > 100 then
set_authority("my_channel", 255)
set("my_channel", false)
end
Timing Utilities
The embedded sequences provide several utilities for timing events.
Iteration
The global iteration
variable is automatically incremented each time the sequence is
run. This can be used to initialize variables during the first iteration of the
sequence, or to define control logic that executes for a specific number of iterations.
Elapsed Time
The global elapsed_time
variable is the number of seconds that have elapsed since the
sequence started. Keep in mind that this value does not strictly follow the
increment * rate
rate. So elapsed_time
for a sequence that runs at 1 Hz and is at
iteration 10 will be very close to, but not exactly 10 seconds.
Elapsed Time Within
The elapsed_time_within
function returns true if the the current elapsed_time
is
within a certain range of values. For example, if we want to check if somewhere between
10 and 11 seconds have elapsed, we can do the following:
if elapsed_time_within(10, 11) then
-- do something
end