How do I get current value of control with a certain id?

How do I get current value of control (option list) with a certain id? The LUA code gives me this answer.

control = controls.get(3)
value = control:getValue()
print (value)

Answer: 18:12:03.886 lua: ControlValue: 0x901304b0

I need answers like 0, 1, 2 and so on…

I find the API quite confusing here and it’s something I misunderstood the same way as you. What you’re getting when you call control:getValue() is not the value but a ValueObject:

Retrieves the Value object of the given control using the valueId handle. The valueId is defined in the preset JSON. If not specified, value will be used as the default valueId.

I solved this in the KnobConnector script by storing the current value of a control in a global map (basically an array of all control values) in the function that would be called when adjusting the control. That function needs to have a signature of (valueObject, value) and value is the current value of that control.

However, according to the docs, this should also be possible on a ValueObject (maybe it’s new?):

:getValue()
Retrieves the current display value of the Value object.

Returns

number, the current display value.

Meaning, you could try:

control = controls.get(3)
value = control:getValue():getValue()
print (value)
1 Like

Thank you very much. It works perfectly. This was very meaningful to me. Thanks again.

2 Likes