Practical examples, Cycling through different timelines – ETC Unison Mosaic Designer v1.11.0 User Manual
Page 218
Unison Mosaic Designer User Manual
start_timeline(t)
start_timeline
is one of the functions provided by ETC and it will start the timeline with the number passed
in as an argument.
It is also possible to define your own functions as part of script. You might do this if there is a block of script that
you know you will need to reuse in a lot of different places. It will be much easier to write the script in one place
and then call it from wherever you need it.
function diff(a, b)
if a > b then
return a - b
else
return b - a
end
end
v1 = 10
v2 = 6
v3 = diff(v1,v2)
Note that the script containing the function definition must have been run before we try to call the function. It is
often useful to have a script that is run by the Controller startup trigger which defines your functions and creates
any tables - other scripts that are run by triggers can make use of those functions and tables.
Practical Examples
In this section we will go through a number of practical examples of how script can be used with a Controller.
These examples are all based on real projects that are installed and working. They do get progressively more
involved, so do not worry if you don't follow the later ones - you will still be able to use script successfully to solve
many problems.
If you are working through this document on your own then look out for where I ask a question and rather than
reading straight on I recommend stopping and trying to answer it yourself. You will only get truly comfortable with
writing scripts by doing it!
Cycling through different timelines
We are installing a wall of RGB LED fixtures in a children's play area. There is a single large button that the kids
are supposed to press. Each time they press it they should get a different colour or effect on the wall.
Each colour or effect would be programmed as a different timeline in Designer. The button will connect to a con-
tact closure and so we will have a single Digital Input trigger. Rather than starting a timeline directly we will
instead run the following script:
-- which timelines should we cycle through?
timeline = { 22, 14, 24, 16, 15, 17, 21 }
n_timeline = 7
-- on first time of running, initialise index
if not index then
- 218 -