I’m not in a position to write your script for you but I can demo the mechanisms that you might find useful.
I’ve just checked the documentation for GP Script and realized that I didn’t mention a very important callback called TimePassing which can be tied to generators such as Ramps and ADSRs. It hasn’t really had that much testing so consider this stuff to be experimental!
Take a look at this screenshot (I’ve pasted the actual code as well, but the screen shot has syntax coloring which makes it easier to read. In particular
I’ve created three widgets, two of which represent your X and Y faders and the third is a “trigger”
Following is a variable of type Ramp. A ramp is a function generator that generates a sequence of values over time where the Y access goes from 0.0 to 1.0
In the initialization, we configure the ramp so that it is a one shot. That means that it will only run ONCE each time you trigger it.
The Trigger widget callback is used to configure the ramp and start it. Here, when you press the trigger button, we set the length to 2 seconds (2000 milliseconds). That means that when the ramp is running, the X value will range from 0 to 1999 and the amplitude (y value) will go from 0.0 to 1.0 linearly over the 2000 milliseconds.
We then enable the rackspace timer for generators. I’m doing this because whenever you leave a rackspace, that timer gets turned off and needs to be turned on manually (normally this would be done in an On Activate callback)
Finally, the On TimePassing callback gets triggered periodically (you can define how fine-grained that callback should be but be careful, if you make it too fine-grained you’ll suck up a lot of CPU cycles)
In the callback, I’m scaling the amplitude individually for each widget so they change accordingly.
Thoughts?
Var
Trigger : Widget // A button widget used to trigger the ramp
xWidget : Widget // My x knob
yWidget : Widget // My y knob
var
myRamp : Ramp // A generator that moves smoothly from 0.0 to 1.0 over some specified time
initialization
SetGeneratorOneShot(myRamp, true) // Generator will only run once when triggered
// Also, check the SetGeneratorCoarseness function
// which can be used to control how often we get called back
// Choose values wisely! You're trading accuracy against CPU cycles
end
// Use this to trigger the ramp
On WidgetValueChanged(newValue : double) from Trigger
if newValue > 0.5
then
myRamp.SetGeneratorLength(2000); // Two seconds
SetTimersRunning(true)
myRamp.EnableGenerator(True)
end
End
// This gets called by the ramp generator as time passes
on TimePassing(timeX : integer, amplitudeY : double) from myRamp
SetWidgetValue(xWidget, Scale(amplitudeY, 0, 1, 1, 0))
SetWidgetValue(yWidget, Scale(amplitudeY, 0, 1, 0.3, 0.7))
//Print("X = " + timeX + " Y = " + timeY)
if (amplitudeY > 0.95)
then SetWidgetValue(Trigger, 0)
end
end