Old Widget Label read by GP Script on Variation Change

I’m trying to write a bit of script which picks up the label value of a widget attached to a scriptlet on a variation change and then use that to change to a plugin preset - this is based on the this post.

However, what I am seeing is that whilst the script can read the correct, new, widget VALUE on a variation change, the LABEL corresponds to the value from the previous variation.

Attached is a simple Gig File - it has one rackspace with two variations. The rackspace has a single widget attached to a widget in the global rackspace that is attached to a scriptlet that only has code to set the parameter values (it doesn’t DO anything) - parameter values are 0.0 = Yesterday, 0.5 = Today, 1.0 = Tomorrow.

Widget Label Not Updated on Variation .gig (39.6 KB)

Simple code in the Global Rackspace:

var knob_day : Widget

// Called automatically after script is loaded
Initialization
    
    Print("***Initialisation***")
    Print(GetWidgetLabel(knob_day))
    
End

// Called when you switch variations
On Variation(oldVariationIndex : integer, newVariationIndex : integer)
    
    Print("***Variation***")
    Print(GetVariationName(newVariationIndex))
    Print(GetWidgetLabel(knob_day))

End


On WidgetValueChanged(newValue : double) from knob_day

    Print("****Widget Value Changed****")
    Print(newValue)
    Print(GetWidgetLabel(knob_day))

End

And likewise in the local rackspace:

var knob_day_local : Widget


Initialization

    Print("**** LOCAL INIT *****")
    Print(GetWidgetLabel(knob_day_local))

End

On Variation(oldVar : integer, newVar : integer)

    Print("**** LOCAL VAR *****")
    Print(GetWidgetValue(knob_day_local))
    Print(GetWidgetLabel(knob_day_local))

End

On WidgetValueChanged(newValue: double) from knob_day_local

    Print("***** LOCAL WIDGET ****")
    Print(GetWidgetValue(knob_day_local))
    Print(GetWidgetLabel(knob_day_local))
    
End

Variations are named as per the value set for the knob in that local rackspace (e.g. Var Yesterday means the widget is set to the parameter “Yesterday”)

Starting with the varation Var Yesterday and selecting Var Tomorrow and then back to Var Yesterday gives this output

You can hopefully see that it picks up the correct widget value (Tomorrow = 1.0, Yesterday = 0.0), but the widget label is from the previous value. This happens both in the local and global rackspaces.

I tried it with a plugin that produces text output to a widget label and the same thing happened so it is not related to the scriptlet.

So, what am I doing wrong?

I believe it’s a timing issue. Do you get a different outcome if you instead use an On ParameterValueChanged callback from your scriptlet.

1 Like

I think that too…
Try not to work with widget labels to get a result.
From what i experienced so far, the captions seem to be lagging behind the widget’s actual value - i (only can) guess that this might be because a caption is probably handled with a much lower priority than a value, which must be available in real time.
Maybe you should try to read the values instead of the labels - maybe that’ll work better?

1 Like

Cheers chaps - yes, very good shout; will try that tonight. If that is the case, then it’s fair enough as the label is really only decorative so should be the last thing thats set. Accessing the parameter directly makes good sense.

I could access the values, but the idea is that it’s much easier to add a new string parameter to a scriptlet when a new preset is added and then recall it by name rather than then having to change another lookup in the gpscript to convert from value back to parameter string.

Anyways, will give it a try tonight and see what happens :slight_smile:

1 Like

@rank13 and @schamass are right.

Then you can read it directly from the PluginBlock ParameterText:

var knob_day : Widget
    set_var : boolean = false
    MyScriptlet : PluginBlock; // <= add this as well as a "MyScriptlet" Handler to your scriptlet
  
// Called when you switch variations
On Variation(oldVariationIndex : integer, newVariationIndex : integer)
    Print("***Variation***")
    Print(GetVariationName(newVariationIndex))
    Print(GetWidgetLabel(knob_day))
    Print(GetParameterText(MyScriptlet, 0)) /// <= It's here!
End
4 Likes

Thanks all, GetParameterText() works perfectly :slight_smile:

Knew it would be an easy fix - GP Community to the rescue again!

1 Like

As always! :wink:

1 Like