var
movStart("Start moving") : Parameter "STOP", "GO" = "STOP"
speed ("Speed of movement") : Parameter 1..30 = 15
position ("Widget Control") : Parameter 0..127 = 0
incstep : integer
Initialization
SetInfoMessage("This scriptlet offers a parameter 'Widget Control' which can be mapped to a widget to automatically turn it up and down within a certain time")
SetDisplayMessage("Click the 'info' button for more instructions")
SetTimersRunning(false)
End
On TimerTick(ms : double)
position = position + incstep
if position >= 127 or position <=0
then SetTimersRunning(false)
end
End
// Called when a parameter value has changed
On ParameterValueChanged matching movStart
If movStart == "GO" Then
incstep=1*speed
SetTimersRunning(true)
Elsif movStart == "STOP" Then
incstep = (-1)*speed
SetTimersRunning(true)
End
End
but I would like to be able to extend the fade time (double or triple or even more…). I searched but I don’t find the solution because the incstep needs to be integer, does anybody have an idea?
In this example, I increased the position parameter to 500, and adjusted the condition in the TimerTick callback accordingly. You’ll find that if you slow the speed of movement down to 1, it takes considerably longer for the position parameter to go from start to finish (and vice versa) than in your original script, which should give you a nice long fade.
var
movStart("Start moving") : Parameter "STOP", "GO" = "STOP"
speed ("Speed of movement") : Parameter 1..30 = 15
position ("Widget Control") : Parameter 0..500 = 500
incstep : integer
Initialization
SetInfoMessage("This scriptlet offers a parameter 'Widget Control' which can be mapped to a widget to automatically turn it up and down within a certain time")
SetDisplayMessage("Click the 'info' button for more instructions")
SetTimersRunning(false)
End
On TimerTick(ms : double)
position = position + incstep
if position >= 500 or position <=0
then SetTimersRunning(false)
end
End
// Called when a parameter value has changed
On ParameterValueChanged matching movStart
If movStart == "GO" then
incstep = (-1)*speed
SetTimersRunning(true)
Elsif movStart == "STOP" Then
incstep=1*speed
SetTimersRunning(true)
End
End