Page 1 of 1

Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 09:09
by Skinnytorus
Hi, all.

1) I have been trying to create a simple cycle with condition within the animation script in yello Transform op:
k:float;
k=time/0.5;
if(k==int(k))
trans.x=3;
else
trans.x=1;

As I can see, the condition is checked just once when time=0 and if(k==int(k)) is true because 0/(any value) = 0 which is integer which gives me 'trans.x=3'.
Then the script considers that trans.x=1. I just wonder if it is possible to make a cycle here? Say, I want to make trans.x=3 when time=0.5 (and k=0.5/0.5 =1 which is integer).
I tried Loop op, but to no avail. :(

2) Since it is not possible to view changes of animated params and variables in real time, is it hard to create an Output op that, when stacked beneath an animated op,
could output to para window all the animated params and variables in real time?
Thank you.

Re: Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 19:15
by ikam
try this :

k:float;
k= time*50; // animation speed
if(k%2 > 1 ) // as time always increment a modulo by 2 return a value ranging 0 to 2 so you can have a cyclic condition (as by ranging >1 from 0.001 to 1.999, you can affect proportionnality)
trans.x=3;
else
trans.x=1;

Re: Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 19:30
by Skinnytorus
Thanks, man.
Could you please expand a bit more on if(k%2 > 1 ) expression? What does k%2 mean?
Edit: Alreay answered. Thanx again!

Re: Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 19:34
by ikam
in programming languages % it's a modulo math operation.

I think wikipedia should explain this more than me and my english :)

http://en.wikipedia.org/wiki/Modulo_operation

Re: Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 19:35
by ikam
by the way, I do not know you, but copy/paste into script crach for me, need to paste line by line :p

Re: Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 19:36
by Skinnytorus
Ahhh. I see now! A very handy thing! :)
Thanks.

Re: Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 20:09
by Skinnytorus
ikam
I tried your solution. It's working, but I want some more from it :)
Here is my code:
k:float;
g:float=0.5;
trans.x=0.5;
k= localtime;
if(k%2 < 1 )
{
g=g+1;
trans.x=g;
}
I want the object to 'cumulatively' move (step) 1 unit on x axis if the remainder of localtime/2 is 0 (i.e. I want the object be at x=1,5 on beat 2,
x=2,5 on beat 4, x=3,5 on beat 6 etc.). Is that possible?

Re: Cycles in the animation script?

PostPosted: Wednesday, 29.August 2012, 23:16
by reEto
always remember: do not make simple operations toooo complex :)