Question about buttons

I have two buttons (Switch on/off), I want that when one is in the ON position the other one is turned OFF and vice versa.

I’m trying with this code but is not working they can stay both in the ON or OFF position at the same time…
Thanks in advance for any help!

function toggleDark()
    if Dark then
        Dark = false
    else
        Dark = true
        Light = false
    end
end

function toggleLight()
    if Light then
        Light = false
    else
        Light = true
        Dark = false
    end
end

defineParameter { name = "Dark", default = false, action = "toggleDark", persistent = true }
defineParameter { name = "Light", default = false, action = "toggleLight", persistent = true }

I don’t think you need a script for this. You could just enable the “Invert” option for one of those switches.

img

Hi @StringAudio

If you define parameters with named arguments you need to use onChanged for the callback and not action.

The condition should probably look something like - if dark then light = false (or the other way around)

At the moment you are trying to change the same parameter.