Hello all, I have a row of 4 widget buttons, (FX1, FX2, FX3, FX4) and I would like to make it to where if all those buttons are disengaged, another button (NoFX) will engage.
I’ve got a very simple and rudimentary script, that kind of works, but anytime any button from FX1-FX4 = 0 it will just turn on the NoFX widget.
Thanks
The script you wrote will fire if any of the four buttons changes. You must not only check that button that it is 0, but also the other 3 buttons (didn’t test this, so you’ll have to check it):
if newValue == 0.0
and GrandFX1.GetWidgetValue() == 0.0
and GrandFX2.GetWidgetValue() == 0.0
and GrandFX3.GetWidgetValue() == 0.0
and GrandFX4.GetWidgetValue() == 0.0
then
GrandNoFX.SetWidgetValue(1.0)
else
GrandNoFX.SetWidgetValue(0.0)
end
2 Likes
May i ask what’s the use of this “No FX” button?
(Just of curiostiy)
Anyway, i streamlined the script to handle any other FX-group in a quite flexible way.
I wrote a user defined function for the whole widget handling of a group (including the NoFx button). So you simply cann call this function with any widget array, without having to change the code. The only requirement is the structure of the widget array: The “NoFx” widget has to be on first place! The actual length of the array should be handled flexibly by the script, so it should not matter if your array has 1 or 12 widgets in a row).
It also prevents to manually switch the “NoFx” button to a wrong state!
Now you’d have to only write one single command for any of your arrays.
I hope this will help you to build your rackspace in a more comfortable way…
var
GrandNoFX, GrandFX1, GrandFX2, GrandFX3, GrandFX4 : widget
//build the widget array with the "NoFx" widget at first position!
GrandFXField : widget array = [GrandNoFX, GrandFX1, GrandFX2, GrandFX3, GrandFX4]
//user function for FX-Group handling
function setFXGroup (FxField : widget array) //receive a widget array to set by function call
var
index : integer
allOFF : boolean = true // assume that at begin all widgets are OFF
//check all FX-widgets from FX1 on (NoFX is index 0) if they are ON
//use the Size(array) function to determine the loop length -> flexibility
for index = 1; index < Size(FxField); index = index +1 Do
if GetWidgetValue(FxField[index]) > 0 Then
allOFF = false //if any of the widgets is ON then set the allOFF falg as false
end
end
//check by boolean flag if all widgets are OFF
if allOFF == true Then
SetWidgetValue(FxField[0], 1.0) // if all FX are OFF then NoFX (index 0 of the array) will be ON
else
SetWidgetValue(FxField[0], 0) // else it will be set to OFF
end
End
Initialization
setFXGroup(GrandFXField) //also set the correct state of the widgets on start
End
// Called when any of several widgets changed
// The widget and index parameters are optional
// react on any switch state of any widget in that group and let the user function handle the correct settings
On WidgetValueChanged(w : Widget, index: integer, newValue : double) from GrandNoFX, GrandFX1, GrandFX2, GrandFX3, GrandFX4
setFXGroup(GrandFXField) //call user function to set the FX-Group widgets for the "GrandFXField" widget array
// this function call can then be used for any other widget group name
End
NoFX.gig (76.0 KB)