Troubleshooting

How to switch scripts on and off

Started by jbgeluid on .

Sign in or create an account to join the conversation.

11 posts

Hi
Brianc has shown a way for scripts to only run if the run_script variable is set - say by a switch
This lets you have a script for say an object that will only run when the flag is set - say by using a Switch or set from another script

If you mean run a script in response to a switch set the script up to execute On Expression and Switch.x (or whatever) to use your switch to run it . .
Cheers
MM
excellent. So simple.

Now, what if you don't have a switch as 'trigger', but a Knob object? A Fader object has a 'touch'-variable z, but the Knob object not. Is it possible to fake a z variable with a Knob object? For example, when Knob.x increases or decreases? How to you express that? Or is there a simpler method?
if (Knob.x ++) return;
if (Knob.x --) return;
The code is wrong, but you probably understand what it should do. If Knob.x changes, return (don't continue with the script). If Knob.x remains the same, continue with the script.
Phil999 wrote:Now, what if you don't have a switch as 'trigger', but a Knob object? A Fader object has a 'touch'-variable z, but the Knob object not. Is it possible to fake a z variable with a Knob object? For example, when Knob.x increases or decreases? How to you express that? Or is there a simpler method?
It's a little ugly, but I guess my approach would be to have a script that runs whenever Knob.x changes that updates a variable that stores the time at which the value was last changed. So something like:
last_change = time;
Then in the script that was dependent on that knob activity, you could put something like:
if(time - Knob.last_change > 2) return;
Which will disable that script if the knob hasn't been changed in the last 2 seconds. With a really small threshold, you can have this be sensitive to within a few milliseconds.
good idea. I tried it out, it doesn't work yet, but using a variable, and an expression-x-script for the 'trigger'-knob is a good method.

I also tried a variable (touch) and two scripts (touch_on, touch_off), but this also didn't work yet.

It shouldn't be too difficult, I'll get it soon I guess. Thank you for your help, very appreciated.
brianc wrote:
if(time - Knob.last_change > 2) return;
Which will disable that script if the knob hasn't been changed in the last 2 seconds. With a really small threshold, you can have this be sensitive to within a few milliseconds.
I want to disable the script when the knob changes, so it's
if(time - Knob.last_change < 2) return;
That is working. Very nice.

Unfortunately, the script I want to prevent being executed does receive MIDI and moves the 'trigger'-knob - I'm running again in a feedback loop, something I wanted to prevent in the first place. My fault, I didn't expect that. I have to rethink this matter ...

Thanks again, your method is working.

My problem is described here:
http://liine.net/forum/viewtopic.php?f=25&t=1732