Dynamic Controller: Get and Set Value
Description
In Lua the value of a controller can be set or get at once using 2 dedicated functions.
Lua Syntax
-- setting the value at once:
local myCtrlMulti = create_controller{kind="dynamic",dimension=4,name="CtrlMulti"}
set_value{ctrl=myCtrlMulti, value={0.7,-2,3.1,-4.9}}
-- for setting the value of a particular rank:
set_value{ctrl=myCtrlMulti, value=3.1, rank=2} -- the rank is zero-based, so '2' means 3rd rank!
-- for creating a smooth transition from the current to the new value:
set_value{ctrl=myCtrlMulti, value={0.7,-2,3.1,-4.9}, time=0.5}
-- getting the value:
local x = get_value(myCtrlMulti)
-- x is table with the same dimension as the controller
-- if the controller is of dimension 1, x is just a number.
Parameters
The set_value(...) function requires the following arguments (2 or 3):
- controller: the controller whose value we want to set. This can be either a reference (myCtrlMulti, i.e. a pointer) or a string ("CtrlMulti").
- value: either a number (if dimension=1 or if rank is specified) or a table (=an array) of values.
- rank (optional): if the rank is passed (zero-based!), the value (a number) is set to the specified rank of the multimensional controller.
- time (optional): use the time (in seconds) parameter for a smooth transition from the current to the new value. This is equivalent to the set-message lisp function.
The get_value(...) function requires the following two arguments (1 or 2):
- controller: the controller whose value we want to query.
- rank (optional) If the zero-based rank is passed, only the value for this rank is returned. The return value is either a number (dimension=1 or specific rank) or a table of values.
★