Page 1 of 1

Going negative in min/max?

PostPosted: Sat May 11, 2013 6:29 am
by Hblade
Why is this not possible? Does min and max not register numbers below 0?

Re: Going negative in min/max?

PostPosted: Sun May 12, 2013 5:00 am
by skydereign
It is possible. You probably are giving parameters you don't intend, or using min when you are using max.

Re: Going negative in min/max?

PostPosted: Sun May 12, 2013 5:23 am
by Hblade
May I have an example?

Re: Going negative in min/max?

PostPosted: Sun May 12, 2013 7:39 am
by skydereign
Here.
some actor -> Create Actor -> Script Editor
Code: Select all
if(min(10, -10)==-10)
{
    r=0;
}

All min and max do is return the smaller/larger of the two values you pass it. Nothing tricky.

Re: Going negative in min/max?

PostPosted: Sun May 12, 2013 5:04 pm
by RippeR7420
Thats nice to know haha. Whenever i need to use min/max I always did it this way.

Code: Select all
x=rand(10);
x=min(max(x, 5), 10);

//or for the negative direction.

x=rand(-10);
x=min(max(x, -10), -5);


Depending on what random/and or/direction I want the actor to move move in.

Re: Going negative in min/max?

PostPosted: Sun May 12, 2013 5:34 pm
by Hblade
Thanks guys =)