andr-ew / nest_

a language of touch for objects by monome [not maintained]
MIT License
21 stars 3 forks source link

allow value to be a function #66

Closed andr-ew closed 3 years ago

andr-ew commented 3 years ago

very useful for binding with the params system or a larger script. in this case, update would simply skip setting a new value to value and just send it to action.

params:add {
    type = 'control',
    id = 'foo',
    controlspec = cs.new(0, 1),
    action = engine.thing
}

foo = _grid.control {
    controlspec = params:lookup_param('foo').controlspec,
    value = function() return params:get('foo') end,
    action = function(s, v) params:set('foo', v) end
}