Widget not firing 'onValue' script when receiving value from device. Bug❔

From the docs:

This script is called when the widget's value updates and when it receives a value.

Input widgets and Text widgets are not firing onValue scripts when they get updates from the device. I can only get Input widgets do that and when I manually edit the widget's value. The way it's written on the docs (and I think they should) these widgets should fire onValue scripts when the value changes regardless if the value is coming from the user or the device.


These widgets are receiving these values from the DAW via OSC (navigating project markers)

onValue is fired but send() has no effect when not triggered by a direct interaction with the interface (Scripting - Open Stage Control).

I was trying to use a custom module and I came up with this:

module.exports = {

    oscInFilter:function(data)
	{
        var {address, args, host, port} = data

		if (address === '/lastmarker/name') {

			var value = args[0].value
			// var loadstate = 
			
			if (@{load_state_delfromstate.value} == 1)
			{
				receive('127.0.0.1', 5001, '/STATE/OPEN', 'States/'+value+'.state')
			
			}
		}

	return {address, args, host, port}
	},
}

I just can't get the value from the widget to fire or not the state loading.
I read a bunch of other similar topics on retrieving a widgets value and using it on a custom module but I wasn't able to make it work. Can you help❔

The code works if the receive function is outside the if. The only thing left is getting the value.

The @{} syntax only work in the client, in widget properties, it's an osc-specific syntax and you probably got an error in the server's console (custom module only support plain javascript). You can't retrieve a widget's value from the custom module, you need to use the oscOutFilter function to make your script aware of value changes and store them in variables if needed.

On a sidenote, the two first arguments of receive() can be omitted safely, and if in a widget property @{load_state_delfromstate.value} can be written @{load_state_delfromstate}.

1 Like

Ooohh that is smart haha

@{load_state_delfromstate.value} can be written @{load_state_delfromstate}
My bad, thank you

Now it's working :smiley:


Custom Module code:

var load_state_button

module.exports = {

    oscInFilter:function(data)
	{
        var {address, args, host, port} = data
		
		if (address === '/lastmarker/name') {

			var markername = args[0].value;
			
			if (load_state_button === 1)
			{
				receive('/STATE/OPEN', 'States/'+markername+'.state')
			}
		}

	return {address, args, host, port}
	},

	oscOutFilter:function(data){
        
        var {address, args, host, port, clientId} = data

		if (address === '/load_state_delfromstate')
		{
			load_state_button = args[0].value
		
		}	
		
        return {address, args, host, port}
    },
	unload: function(){
    },
}

@rafaews this looks really interesting. Would you share your rpp and osc files?

Sure. I'll do that later today.

@GeneralMidi

  • The 'States' folder should be put inside Open Stage Control's install folder, if you don't wanna rewrite the custom module.
  • It will only work properly if you run 'State File MOD' script inside the 'States' folder.(There's a compiled .exe version if you don't wanna install AutoHotkey.

I don't know how much work would be to add a property to the widgets like 'Save State' [true/false] to avoid the need of editing the .state files but I personally think it's a good feature for the App. I've seen people talking about having presets and this could be a viable option. @jean-emmanuel said he'll look into it but didn't specified which would be the solution. Is this widget property feasible❔

Open Stage Control.zip (529.8 KB)

Thanks so much!

No problem.

PS: I realized later that the watcher doesn't have to be checking the files on a loop. I can send a message from Open Stage Control (button triggered) to the script and tell it to check the files.
I'll do that later today. I'll probably open a topic too since I didn't see any topics on that kind of way to save presets.

@GeneralMidi
I just rewrote the code of the watcher for the state files. Now it responds to a message from the Save Button.

Check it out.

State File MOD v2.zip (6.5 KB)