Troubleshooting
stupid save value.x question
Started by vmy on .
Sign in or create an account to join the conversation.
hi all 
im newbee in scriping and programming. think its a very simple problem and hope someon can help me!
i want to control fadervalue with a button. therefor i used a switch. when switch is on fader value should be 0. when switch is of fader value should be at the last value. hope you anderstand what i want to do?
therefor i creat the following script. on is switch object. value is a normal fader:
decl temp;
if (on.x==1)
{
temp=value.x;
value.x=0;
}
else if (on.x==0)
{
value.x=temp;
}
in my oppinion it should be work? but it seems the value cant be saved by the temp variable?
maybe someone has also a quick solution to use same for a multislider. to turn off every slider seperat with a special switch. think therefor i must
use vectors.
greetings
vmy
im newbee in scriping and programming. think its a very simple problem and hope someon can help me!
i want to control fadervalue with a button. therefor i used a switch. when switch is on fader value should be 0. when switch is of fader value should be at the last value. hope you anderstand what i want to do?
therefor i creat the following script. on is switch object. value is a normal fader:
decl temp;
if (on.x==1)
{
temp=value.x;
value.x=0;
}
else if (on.x==0)
{
value.x=temp;
}
in my oppinion it should be work? but it seems the value cant be saved by the temp variable?
maybe someone has also a quick solution to use same for a multislider. to turn off every slider seperat with a special switch. think therefor i must
use vectors.
greetings
vmy
I guess it doesn't work because the variable is inside the script. Creating a variable (expression) and include it in the script should solve the problem.
Create a new empty expression (x= button in desktop editor) inside your fader - call it lastX (for example).
Create a script in your fader - lets name the script setLastX.
Set this script to execute on expression z, and then use the dropdown menu at the far right of the scripting window to execute when z drops to zero (arrow pointing down).
Inside the script type:
lastX = x;
This script will be saving the fader's value as lastX everytime z drops to zero - in other words everytime you stop touching the fader, in other words every last value as you want. (Assuming physics are off for the fader)
Now, inside your button type this script
If (x==1) {value.x = value.lastX;} else {value.x = 0;}

Create a script in your fader - lets name the script setLastX.
Set this script to execute on expression z, and then use the dropdown menu at the far right of the scripting window to execute when z drops to zero (arrow pointing down).
Inside the script type:
lastX = x;
This script will be saving the fader's value as lastX everytime z drops to zero - in other words everytime you stop touching the fader, in other words every last value as you want. (Assuming physics are off for the fader)
Now, inside your button type this script
If (x==1) {value.x = value.lastX;} else {value.x = 0;}
very nice!!
it runs....
thanks alot.
now i will test this templet to use it with 10 faders in multislider and 10 button.
hope i now can solve this problem....
greetings
vmy
save.jzml
it runs....
thanks alot.
now i will test this templet to use it with 10 faders in multislider and 10 button.
hope i now can solve this problem....
greetings
vmy
save.jzml
just have modified the templet to use also multislider by painting over switchs and it runs very well!!!!
think its a very stupid solution. think i also can use variable for vectors in multislider, but i only need 10 and for this its running well.....
greetings and thanks alot for your help !!
vmy
save2.jzml
think its a very stupid solution. think i also can use variable for vectors in multislider, but i only need 10 and for this its running well.....
greetings and thanks alot for your help !!
vmy
save2.jzml
There's a simpler way to achieve what you achieved in "save2" with the use of vectors and a loop.....
save2-usingloops.jzml
Yet though, it still isnt "right" - both my example attached above and yor version....Draw some values on the sliders, switch on button 1 and ALL the sliders go to zero not only the first one....Thats not what we hoped for, was it?
Here is the correct functionality!

save3.jzml
save2-usingloops.jzml
Yet though, it still isnt "right" - both my example attached above and yor version....Draw some values on the sliders, switch on button 1 and ALL the sliders go to zero not only the first one....Thats not what we hoped for, was it?
Here is the correct functionality!
save3.jzml
yes!! great! i understand. but i wasnt able to get this nice solution.
only one thing i missed. maybe you also have a solution for this problem? but its only a blemish.
when buttons are of i can change the value of the fader. to save the value i must put the button on and of. maybe there can be a solution that i cant change the faders value when the corresponding button is off? hope you understand?
thanks for this very nice templet. i have saved it as modul to use it also in other templets!!!
greetings
vmy
only one thing i missed. maybe you also have a solution for this problem? but its only a blemish.
when buttons are of i can change the value of the fader. to save the value i must put the button on and of. maybe there can be a solution that i cant change the faders value when the corresponding button is off? hope you understand?
thanks for this very nice templet. i have saved it as modul to use it also in other templets!!!
greetings
vmy
I think you would be better off by using two buttons - one to reset the fader to zero (as now our buttons does when it's turned to off) which would be a "push button" not a switch (in Lemur terminology, a "pad") and one to save the fader position as a "preset". There is a very nice tutorial hanging around somewhere in the forums about saving "presets" - this would allow you to "recall" not one, but all faders into their position with the push of a button and have not one but many "presets" available. Let me know if you need an example to get you started! 
here's the dual buttons approach actually - no preset saving needed - I think it is much more clear and intuitive than our previous efforts!
And its better code-wise!
save4.jzml
save4.jzml
wowowowo
softcore your the greatest!!! just have tested your solution. runs very well.
i must learn very much to understand your code..... uuuuuhps.
thanks alot! i worked with a kyma and therefor its fantastic to programm special controllers. lemur is an fantastic tool for this kind of work.
greetings
vmy
softcore your the greatest!!! just have tested your solution. runs very well.
i must learn very much to understand your code..... uuuuuhps.
thanks alot! i worked with a kyma and therefor its fantastic to programm special controllers. lemur is an fantastic tool for this kind of work.
greetings
vmy
Lemur is indeed a great app! Actually its your dream midi-OSC controller come true! Give it some time to learn how to script and you 'll smile like a litle kid with all the things posible to achieve!
I cant stop saying that I bought an iPad just for Lemur and it was one of my best decisions on my music making endeavors.