Possible to switch multiple toggles at the same time?

if I have 10 toggle swithes and they all do something but then I want to do smaller presets like for example Preset 1 being Toggle 1,4 & 8 on and another preset where 2, 5 & 9 are on, is that possible?
thank you!

You can create a button that sets multiple widgets at once with its script property and the set() function.

@jean-emmanuel can you give us a little example.

it is different from @Alex.Vartzbed

1.) i have a menu widget (with json values)
2.) in a panel i want to show some buttons (and hide otheres ), depending on the menu selection
3.) the value of the panel widget is updated with @{panelname.value}

I want to hide (visible and interaction set to false) or show some buttons in the panel depending on its value.

Can you give me some codesnippets for this (i guess a custom module is the best solution here -> i couldn’t execute a script on value change, some easy examples would be helpful here too)

Thanks!

// setting multiple widgets from a single script
set("widget_a", 1)
set("widget_b", 0)
set("widget_c", 1)
// etc

in a panel i want to show some buttons (and hide otheres ), depending on the menu selection

What I do usually is simply to define each widget’s visible property with conditional statements (if visible is false there is no need to change interactive);

#{@{switch_id} == 0}

This will return true if the switch’s value is 0, false otherwise. It’s possible to combine multiple conditions:

#{@{switch_id} == 0 && @{button_id} == 1}

3.) the value of the panel widget is updated with @{panelname.value}

I’m not sure what you mean by this, but anyway:

  • @{panelname.value}: the “.value” part is not needed
  • panels can’t store arbitrary values, their value is only of use if they contain tabs, in which case it’s used to define which tab is selected.
1 Like

thanks for the examples, still don’t get it how to use the script property…( assume having menu xxx, and matrix yyy, and then in the script property of xxx, i write in get(“yyy”,height) -> ???)

Because of another forum question:

i decided to go with a matrix object.
With a menu i switch 4 categories, depending on the selection the corresponding matrix is showing up.

Now the Menu should stick to the matrix (the height differs)
Menu selection A -> get the height of Matrix A, Menu B -> height of Matrix B

in the menu top property i tried:

#{ if (@{collType.value == E-HEAVY}) {
return @{E-HEAVY.height}
}
if (@{…}) {
return @{xxxx.height}
}
}

thanks!

#{ if (@{collType.value == E-HEAVY}) {

You can’t use #{} this way, you must use the JS{{}} block if you don’t wan’t your code to be prepended with a return statement automatically (which makes your code invalid). See https://openstagecontrol.ammd.net/docs/widgets/advanced-syntaxes/#javascript-code

Also, the statement “@{collType.value == E-HEAVY}” doesnt comply with the syntax rules described in the documention, I think what you wanted to write was something like

JS{{
if (@{collType} == "E-HEAVY") {
  return @{E-HEAVY.height}
}
}}

I wanted to ask - is there a way to have a wait in between commands when sent via one button?

when i use the set command i mean… thank you!

set(“ButtonA”, 1)
wait
set(“ButtonB”, 1)
wait
set(“ButtonC”, 0)

… any way to do this?

thank you!

You can use the setTimeout function (https://www.w3schools.com/jsref/met_win_settimeout.asp).

setTimeout() and setInterval() functions allow you to execute a piece of JavaScript code/function at a certain point in the future. setInterval repeats the call, setTimeout only runs it once.

JavaScript setTimeout(expression, timeout); runs the code/function once after the timeout. It is a time based code execution method that will execute script only one time when the interval is reached, and not repeat again unless you gear it to loop the script by nesting the setTimeout object inside of the function it calls to run. If geared to loop, it will keep firing at the interval unless you call clearTimeout(). If you want something to happen one time after some seconds Then use setTimeout... because it only executes one time when the interval is reached.

setTimeout(function() {
  console.log('Wait 3 seconds and I appear just once');
}, 3000);

setInterval(expression, timeout); runs the code/function repeatedly, with the length of the timeout between each repeat. It is a time interval based code execution method that has the native ability to repeatedly run specified script when the interval is reached. It should not be nested into its callback function by the script author to make it loop, since it loops by default. It will keep firing at the interval unless you call clearInterval(). If you want to loop code for animations or clocks Then use setInterval.

setInterval(function() {
  console.log('Every 3 seconds I appear on your console');
}, 3000)

It's worth noting that setTimeout and setInterval are slightly different in open stage control : Scripting - Open Stage Control

Noted. Now, how much is it worth? :sunglasses: