Skip to content

Lua: Get a Controller's Value with get_value

Description

In Lua context, get the value of a controller as a single value or table.

Lua Syntax

-- setting the value at once:
local ctrl1 = create_controller{kind="dynamic",value=4.7,name="Ctrl1"}
local ctrl2 = create_controller{kind="dynamic",value={0.7,-2,3.1,-4.9},name="Ctrl2"}
-- getting the value:
local x = get_value(ctrl1) -- x = 4.7
local y = get_value(ctrl1) -- y = {0.7,-2,3.1,-4.9}
local y1 = get_value(ctrl1,1) -- y1 = -2 ⚠️ the rank is zero-based!

Parameters

The get_value function requires one or two arguments:

  • 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.


★     ★