Page 1 of 2

stupid save value.x question

Posted: 23 Oct 2013 16:17
by vmy
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

Re: stupid save value.x question

Posted: 23 Oct 2013 17:23
by Phil999
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.

Re: stupid save value.x question

Posted: 23 Oct 2013 22:41
by Softcore
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;}


;)

Re: stupid save value.x question

Posted: 24 Oct 2013 15:04
by vmy
very nice!!
it runs.... :D

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

Re: stupid save value.x question

Posted: 24 Oct 2013 16:39
by vmy
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
with multislider
(14.68 KiB) Downloaded 63 times

Re: stupid save value.x question

Posted: 24 Oct 2013 22:09
by Softcore
There's a simpler way to achieve what you achieved in "save2" with the use of vectors and a loop.....
save2-usingloops.jzml
(8.35 KiB) Downloaded 56 times
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
(10.54 KiB) Downloaded 65 times

Re: stupid save value.x question

Posted: 25 Oct 2013 14:23
by vmy
yes!! great! i understand. but i wasnt able to get this nice solution. 8-)

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!!! :P

greetings
vmy

Re: stupid save value.x question

Posted: 25 Oct 2013 14:33
by Softcore
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! ;)

Re: stupid save value.x question

Posted: 25 Oct 2013 14:44
by Softcore
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!

Re: stupid save value.x question

Posted: 25 Oct 2013 16:45
by vmy
wowowowo :D

softcore your the greatest!!! just have tested your solution. runs very well.
i must learn very much to understand your code..... uuuuuhps. :P

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