Var
group1_sound1 : PluginBlock
group1_btn1 : Widget
On WidgetValueChanged (btval : double) from group1_btn1
if ModifierKeys() == 2 and btval > 0.5
then OpenPlugin(group1_sound1)
Else ClosePlugin(group1_sound1)
end
If btval >0.5
then SetPluginBypassed(group1_sound1, false)
else SetPluginBypassed(group1_sound1, true)
end
End
You have to put in the other declarations and statements before you End the sequence from On WidgetValueChanged.
That likely does work and I can test it in a different gigā¦ but in my gig, that crashed GP completely and I suspect this is why:
I have another part of my script with the following variables:
Var
TimerStarted : Boolean
StartTime : double
Delay : double
Now this is just a guessā¦ because this is quickly getting over my head, but I think the true, false syntax is creating a feedback loop of somekind and hanging GP.
I myself tried almost what you sent using āfalseā last night and it crashed GP.
Hereās the rest of that script I am referring to:
>
> //leslie break script//
>
> initialization
> TimerStarted = false
> Delay = 410
> SetTimersRunning(true)
> end
>
> on Activate
> TimerStarted = false
> SetTimersRunning(true)
> end
>
> On WidgetValueChanged(newValue : double) from speed1
>
> if ParamToMidi(newValue) >= 20
> and ParamToMidi(newValue) <= 110 then
> if TimerStarted == false then
> SetTimersRunning(true)
> TimerStarted = true
> StartTime = TimeSinceStartup()
> end
>
> else
> brake1.SetWidgetValue(0.0)
> brake2.SetWidgetValue(0.0)
> brake3.SetWidgetValue(0.0)
> SetTimersRunning(false)
> TimerStarted = false
> end
>
> End
>
> on TimerTick(ms : double)
> if TimeSinceStartup() >= StartTime + Delay then
> brake1.SetWidgetValue(1.0)
> brake2.SetWidgetValue(1.0)
> brake3.SetWidgetValue(1.0)
> end
> end
I am putting ALL of my Var for all my script sections at the very top of my script to keep that in one place, I donāt know if where those are expressed matters or not.
While Iād ultimately like to know if I am correct in my assumption that true/false is the culprit of the crashingā¦ I also wonder if itās possible to get around this by using an integer or double instead but when I try that I get an error of incompatible value.
I can confirm that if I remove my //leslie break script// from my overall script, then adding the SetPluginBypassed action doesnāt crash GP so while I donāt understand why this is, my hunch is correctā¦ itās a conflict with the boolean true/false that creates a ādeath spiralā.
@dhj I know were in un-supported territory here but just a FYIā¦ when this crash occurs it doesnāt dump out to the GP crash notification screenā¦ I just get the GP has stopped working and will be reported to Windows screen.
āStopped workingā generally just means that Windows didnāt detect any GUI activity after a certain amount of time passed. Thatās generally due to a hang and eventually Windows will kill it. So if you are in GPScript and have setup an infinite loop such that nothing else can happen then that is essentially a hang, not a crash
So I think I have solved the issue that caused the hang just by reordering my scripts.
If I put the SetPluginBypassed script before my //leslie break script// both scripts function normally and clicking the bypass button doesnāt hang GP.
But if I reverse the order of these scripts, clicking the bypass button does hang GP.
> Var
> TimerStarted : Boolean
> StartTime : double
> Delay : double
>
> brake1, brake2, brake3 : Widget
> speed1, speed2, speed3 : Widget
>
> group1_btn1 : widget
> group1_sound1 : PluginBlock
>
> //bypass button open plugin script//
>
> On WidgetValueChanged (btval : double) from group1_btn1
> if ModifierKeys() == 2 and btval > 0.5
> then OpenPlugin(group1_sound1)
> Else ClosePlugin(group1_sound1)
> end
> If btval >0.5
> then SetPluginBypassed(group1_sound1, false)
> else SetPluginBypassed(group1_sound1, true)
> end
> End
>
>
> //leslie break script//
>
> initialization
> TimerStarted = false
> Delay = 410
> SetTimersRunning(true)
> end
>
> on Activate
> TimerStarted = false
> SetTimersRunning(true)
> end
>
> On WidgetValueChanged(newValue : double) from speed1
>
> if ParamToMidi(newValue) >= 20
> and ParamToMidi(newValue) <= 110 then
> if TimerStarted == false then
> SetTimersRunning(true)
> TimerStarted = true
> StartTime = TimeSinceStartup()
> end
>
> else
> brake1.SetWidgetValue(0.0)
> brake2.SetWidgetValue(0.0)
> brake3.SetWidgetValue(0.0)
> SetTimersRunning(false)
> TimerStarted = false
> end
>
> End
>
> on TimerTick(ms : double)
> if TimeSinceStartup() >= StartTime + Delay then
> brake1.SetWidgetValue(1.0)
> brake2.SetWidgetValue(1.0)
> brake3.SetWidgetValue(1.0)
> end
> end
If I reverse the order like follows, when I click on group1_btn1, then I get the hang.
> Var
> TimerStarted : Boolean
> StartTime : double
> Delay : double
>
> brake1, brake2, brake3 : Widget
> speed1, speed2, speed3 : Widget
>
> group1_btn1 : widget
> group1_sound1 : PluginBlock
>
> //leslie break script//
>
> initialization
> TimerStarted = false
> Delay = 410
> SetTimersRunning(true)
> end
>
> on Activate
> TimerStarted = false
> SetTimersRunning(true)
> end
>
> On WidgetValueChanged(newValue : double) from speed1
>
> if ParamToMidi(newValue) >= 20
> and ParamToMidi(newValue) <= 110 then
> if TimerStarted == false then
> SetTimersRunning(true)
> TimerStarted = true
> StartTime = TimeSinceStartup()
> end
>
> else
> brake1.SetWidgetValue(0.0)
> brake2.SetWidgetValue(0.0)
> brake3.SetWidgetValue(0.0)
> SetTimersRunning(false)
> TimerStarted = false
> end
>
> End
>
> on TimerTick(ms : double)
> if TimeSinceStartup() >= StartTime + Delay then
> brake1.SetWidgetValue(1.0)
> brake2.SetWidgetValue(1.0)
> brake3.SetWidgetValue(1.0)
> end
> end
>
> //bypass button open plugin script//
>
> On WidgetValueChanged (btval : double) from group1_btn1
> if ModifierKeys() == 2 and btval > 0.5
> then OpenPlugin(group1_sound1)
> Else ClosePlugin(group1_sound1)
> end
> If btval >0.5
> then SetPluginBypassed(group1_sound1, false)
> else SetPluginBypassed(group1_sound1, true)
> end
> End
Both script //sections// work independently no issueā¦ but adding another instance of using the Boolean true, false in the same script, depending on the order it is used, creates the hang.
I donāt have time to do user script debugging (and frankly it doesnāt hepp that your script is not properly indented to at least make it readable) but would note that your OnTimerTick should actually stop the timer once it reaches the correct time otherwise itās going to just keep setting those widget values on every tick.
This is a single script ā not two separate scripts. The order of callbacks should not matter one bit.
sorry about the indentationā¦ it happens when I paste in for some reason, itās not like that in the script.
yes, i get that itās one scriptā¦ but the order of the callbacks is definitely what determines if the crash is triggered or not. Iāve tested that numerous times and itās the variable.
Iāll try to figure out the Timer, thanks for the suggestion.
Iām attaching the exported script in case anyone wants to take a look. The way this is exported is the way in which it does not crash.
Bump for radio button widgets.
Iāve got a group of seven mutually exclusive buttons I want to automate. I will dig in with GPScript but also register my interest here.
I tried to follow the file you provided, and when switching between variations, the button just blinks and recovers, not visually switching or mutual exclusion, i.e.: the led indicator is lit but does not stay on, and doesnāt work as a constant reminder of the current state (e.g. out of a certain page).
Is it possible to modify the script code to help me realize a toggle variation like the one in your file?
No need for scripting anymore, there is an in-built function for radio buttons since V4.7 (I guess).
Just put the buttons into the same radio group (must not be 0) and you are good to go!
Search the manual for āradio groupāā¦ it should be well documented.