Script questions and possible FR (setProp)

I understand that set sets only a widget's value.

set("switch_1", 1)
set("switch_2", 2)

What if I want to change for example the label on the same widget, or a different widget?

I can get the property getProp("button_37","label") but unsure how to set it.

setProp() would be cool.

I tried this in the script property console.log(@{button_37.label}) to see if I could access the label property, but it came back with a Reference Error.

so this doesnt work... @{button_37.label} = "Test"

Also, I'm not sure why this happens

console.log(this) //prints "null"
console.log(@{this}) //prints nothing!

setProp() would be cool.

As of 1.9.4 you can use the VAR{} syntax to allow modifying a property from a script. For example you'd write VAR{foo, 1} in a property ("foo", is the name of the property, "1" is the default value for that block), and from any script: setVar('widget_id', 'foo', 2)

console.log(this) //prints "null"

A short explanation: Xy pad to knob filtered by a dropdown - #7 by jean-emmanuel

console.log(@{this}) //prints nothing!

Don't use @{} in scripts, use get() or getProp()

Ok, I'll keep trying to understand this

Thanks for the VAR{} syntax. I still think setProp() would compliment getProp() rather nicely...

setProp() won't happen because it doesn't fit with how properties work in open stage control.

In a button I have VAR{'visible',true} in the visible property, and the button is visible.

In another button I have in the script property

setVar('button_1', 'visible', false)
console.log(getVar('button_1','visible'))

console shows false but the button remains visible after hitting this second button. I've tried various combinations of quotes vs no quotes but I'm not sure if I'm doing this right.

1 Like

This one is on me, hotfixed 1.9.5 is on the way. (and there should be no quotes in the VAR{} syntax, it's not really javascript)

follow the same idea to answer some else in the forum```

set a fader visibility and interaction using an other button

set('fader_1', 'interaction', false)
set('fader_1', 'visible', false)
console.log(getVar('fader_1','visible'))

in the fader
VAR{visible,true}
VAR{interaction, true}
the log send me 'true' and get no other result.

You're calling set() instead of setVar().

1 Like