SkarlathAmon
20th July 2005 03:39 UTC
Working Logic?
Is it just me or is the If, Above and Below functions broken? I've tried multiple tests to see if they work and it appears that they make no change whatsoever to anything.
I may be using them wrong but...
init: m=0;n=800
beat: if(0,m=.99,m=-.99)
perpoint: x=m; y=m
then the moment i get a beat in the music, the point should move to the bottom right, (or if the documentation's reversed the top left) but it does neither. Can anyone tell me what i'm doing wrong?
thanks
dirkdeftly
20th July 2005 04:50 UTC
either a) avs is not registering beats or b) there's something wonky with your code. for one, you don't need to render 800 points, and if nothing's showing up at all with that, you're probably rendering lines. try reinstalling winamp and see if that helps.
btw, +y is bottom, +x is right, so the point ought to move to the top left.
SkarlathAmon
20th July 2005 06:41 UTC
I had just left it on what it defaulted to for the spiral, even when i put it in the frame code, or the point code, i can't make it evaluate the above functions. I have winamp on two machines, neither of which can successfully use it. Though both are using AVS 2.81b.
But your saying that my code should is correct for the if statement right?
jheriko
20th July 2005 11:47 UTC
beat: if(0,m=.99,m=-.99)
you shouldnt expect that to work. I wouldnt, in ANY programming language. wspecially evallib with its simple and consistent syntax.
read the expression help. PROPERLY.
above() below() or equals() return 1 if the expression they represent is true and 0 if false. so above(2,3) is 0, below(5,6) is 1 etc... ifs first parameter determines the code path. 1 it executes the then parameter, 0 and it executes the else parameter.
try looking at other presets if you find the expression help hard.
look at your current code and your if statement is always comparing zero. so it always runs the else path. which is an invalid block of code anyway. so it does nothing.
SkarlathAmon
20th July 2005 17:23 UTC
... I know how to program. I know what they do, i read the help MULTIPLE times. My problem is... it runs NEITHER command. My question was that if anyone else was having a problem with IF not working, or if my syntax was wrong, but you have confirmed that my syntax is right to make the true value trigger...
^..^
20th July 2005 18:09 UTC
First: YOUR CODE IS WRONG!
as jheriko already said: if you're really using this code:
Originally posted by SkarlathAmon
init: m=0;n=800
beat: if(0,m=.99,m=-.99)
perpoint: x=m; y=m
in AVS it simply won't work. Cause it's not AVS syntax!
btw: if there is code in the beat box, it'll only be executed whenever AVS detects a beat.
So, if you want to have a point jump to the opposite corner whenever there is a beat, just do that:
init: m=0; n=1; <- you only need one single point (as you said yourself)
frame: m=.99;
beat: m=-.99;
perpoint: x=m; y=m
now your point will be in the opposite corner whenever there is a beat.
If you still want to use the if() function
(though it would be pretty stupid, cause we already found a much faster and simpler solution), then do the following:
if( b , assign(m,-.99) , assign(m,.99) )
'b' is a variable used by AVS which is either 1
(if there currently is a beat)
or 0
(when there isn't a beat).
And what assign() does, should be pretty obvious.
Now, as long as b has the value 1 the if-function processes the code in the middle-part: assign(m,-.99). Otherwise (if b has the value 0) the last part of the code will be processed: assign(m,0.99).
wow, guess that is enough explanation...
^..^
20th July 2005 21:53 UTC
hehe...
but wait pak! The very last ultimatum hasn't run out yet!
SkarlathAmon
21st July 2005 07:37 UTC
Thanks :D
Ah and that was my problem, not using assign. it was my understanding that = did the same thing, but i guess i was wrong.
thanks
^..^
21st July 2005 17:12 UTC
no prob...
and don't forget that the if(0... part doesn't do what you wanted it to either!
StevenRoy
22nd July 2005 03:38 UTC
The major difference between = and assign() is that the former doesn't work inside functions, such as if(). However, you can just as easily use = if you rearrange the equation a little. (Yes, if() is a function. It's like the ?: operator in C and Java and other languages.)
For example, the following three lines are equivalent:
if(b,assign(m,-.99),assign(m,.99));
assign(m,if(b,-.99,.99));
m=if(b,-.99,.99);
Of course, if you're using the "b" variable to determine when there's a beat, it's usually a good idea to consider dividing the code into the "frame" and "beat" sections. There's a good example of this posted by ^..^ about five posts ago.