Callback function not working

So I am just getting into setting up my ElectraOne for a project I am working on. I am using the developer docs and found this example for a callback function: Preset Lua extension | Electra One Documentation

function highlightOnOverload(valueObject, value)
    if(value > 64) then
        control:setColor(ORANGE)
    else
        control:setColor(WHITE)
    end
end

If I paste this data into the script editor and send it to the Electra, nothing happens with the control that I have assigned the function to.

The other formatting functions work great.

Are there any obvious things I have missed?

1 Like

I think I see: you haven’t specified in the function what the “control” object is. Tus, the statement control:setColor doesn’t know what control to refer to.

What you need to to is to extract the control object out of valueObject, or in case you only use the function for this single control, refer to it as control #9

Thanks. So I need to get the control first like this?:

-- print out a name of given control

function printName(controlId)
    local control = controls.get(controlId)
    print("Name: " .. control:getName())
end

from: Preset Lua extension | Electra One Documentation

It should be a function I can apply to any control (slider).

Usually you can just use:

control = valueObject:getControl()

To return the control. That way, any control using that method has it uniquely assigned at that time

2 Likes