Troubleshooting
How to switch scripts on and off
Started by jbgeluid on .
Sign in or create an account to join the conversation.
Is there a way to switch scripts on and off with buttons? I did read the manual...
Subject: Re: Switch scripts on and off
You could create a variable called run_script or something, and start those scripts with:if(!run_script) return;
Then just set run_script to 1 when you want it to run, and 0 otherwise.brianc,
thanks for your reply, but can you be more specific? I'm a beginner, sorry..
thanks for your reply, but can you be more specific? I'm a beginner, sorry..
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
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
Sure, here's an example template that (I hope) demonstrates how this can be done.jbgeluid wrote:brianc,
thanks for your reply, but can you be more specific? I'm a beginner, sorry..
script_onoff.jzml
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?
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.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: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?
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.
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.
Thanks Brianc and Phil999 for your input! This realy helps.
Jurgen
Jurgen
I want to disable the script when the knob changes, so it'sbrianc wrote: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.if(time - Knob.last_change > 2) return;
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
of course I can't use x, I should have known. So I simply use a switch now to manually toggle the scripts.
http://liine.net/forum/viewtopic.php?f=25&t=1732&p=7415#p7415
But this trick with the time value is very clever.
Again I learned quite a bit this week, thank you all. It's a good feeling to have control over Lemur.
http://liine.net/forum/viewtopic.php?f=25&t=1732&p=7415#p7415
But this trick with the time value is very clever.
Again I learned quite a bit this week, thank you all. It's a good feeling to have control over Lemur.