Trigger button using OSC feedback from another computer

I'm sending (from another pc):

(DEBUG, OSC) In: { address: '/feedback/button/01', args: 25 } From: 10.20.96.12:52543

I want to trigger a specific widget that starts a timer, using the arguments passed via OSC.
I set up a test button with this address, and the incoming ip as the "target" - but nothing happens.

What am I doing wrong?

Setting the target is not necessary to receive osc messages. Buttons only receive messages that match their on/off values, if you want to receive any value use a script widget or and input widget.

1 Like

...match their on/off values how?

Any OSC command with the argument "13" will automatically trigger all buttons with the value 13?

Do you have any example that explains this?

EDIT:
Or should I write the osc-adress in the button value field?

If address is /button, on is 13 and off is 0, the button will be able to receive /button 13 and /button 0.

1 Like

Ah ok... is there any way to fetch the OSC-args and display them in a text field for instance?

text and input (and script) widgets will accept any arguments you'll just need the address to match.

Ok, got it!

Can it handle multiple arguments?

Yes it can, did you try ?

Yes, but don't really understand how to use it?

Sending args: 0, "stop" wont trigger the button (and run the script), since i can't have the value: 0 "stop" in the button value field...

Have not found anything in the documentation regarding handling multiple arguments... maybe I just searched in the wrong place?

As I said the button widget don't accept multiple arguments (except if the preArgs property is set but it will only allow you to have fixed arguments before the widget's actual value which can only be equal to its on or off properties). By script I meant script widget, but to make it simple create a text widget with any osc address, sending multiple arguments to this address will work and they'll be displayed in the widget.

Ah ok.. I'll try that.

Another one: all of a sudden setVar seems to have stopped working.
Tried creating a new button to make sure nothing else was interfering:

setVar('button_1', 'text', 'testing')

And then recalling it inside the button_1 html property like such:

VAR{text}

. But nothing. No errors, nothing...

Are there any other variables or methods that could interfer with setVar() somehow?
Thoren Arena Innebandyhall 1.1.json (327.3 KB)

The issue is caused by a clone that duplicates panel_1 (and thus button_1), the clone of that button interferes with the command because it has the same id, I'll update setVar() so that it affects all widgets that match provided id, meanwhile you can use "this" instead to make sure the command affects the calling widget.

Seems like setVar() doesn't work at all inside panel_1, neither of these work:

setVar(this, 'text', 'asdf1234')
setVar('the_button_3', 'text', 'asdf1234')

However, they both work outside of panel_1.

"this" must be enquoted to work. (now it occured to me I can make it work without quotes too, could avoid some mistakes)

Yes, "this" works with quotes - except in one script where i check if any other buttons are toggled, and need to change their 'text' variable (not the same object):

globals.fadeOutOtherPlayerButtons = function(sex, currentId, value) {
  for (let otherId = 1; otherId <= 100; otherId++) {
    if (sex + '_player_presentation_' + currentId != sex + '_player_presentation_' + otherId && get(sex + '_player_presentation_' + otherId, value) != 0) {
      set(sex + '_player_presentation_' + otherId, 0)
      setVar(sex + '_player_presentation_' + otherId, 'text', getProp(sex + '_player_presentation_' + otherId, 'comments'))
      setVar("this", 'text', '>>>')
    }
  }
}

Any other workaround for that?

Just in case, please try with the latest version. Did you try commenting out some lines to verify there's no conflict between your calls (set() comes to mind as to could well trigger some script)

Ah, the newest version solved it!

Nice feature with the syntax highlighting btw :slight_smile:

However, i noticed something else rather wierd... when i toggle a button, and the other button de-toggles, it runs the fadeOut function twice most of the time, but not all of the time...? (should only run once)

Could that be related?
Thoren Arena Innebandyhall 1.1.json (549.1 KB)

Adding this 3rd argument in the set() call of fadeOutOtherPlayerButtons will prevent that (otherwise the script is triggered by this call): {script:false}

set('id', 0, {script:false})

Thanks, it worked!