View Full Version : Really simple question.
DaveWortley 02-11-2009, 10:17 AM a = 1.5
if (1 < a < 2) == true then
(
print "result"
)
For some reason I always get stuck with If statements in maxscript. How do I make this work?
|
|
groutcho
02-11-2009, 10:28 AM
if (a > 1 AND a < 2) then ...
You don't need true/false evaluation
Gravey
02-11-2009, 10:35 AM
i'm pretty sure maxscript sees that code like this:
1. 1 < 1.5 -- evaluates to true, now i can take this new data and move on:
2. true < 2 -- WTF i'm confused so i'll throw an appropriate error: No ""<"" function for true
you need to say: 1 < a AND a < 2
EDIT: too quick groutcho, and yes you dont need to compare to true because the result of comparing the numbers will always be a boolean
DaveWortley
02-11-2009, 10:44 AM
Cheers guys, this also appears to work.
if (a > 1) == true and (a < 2) == true then
Piflik
02-11-2009, 11:38 AM
Yeah, but as groutcho and Gravey said, the '== true' is completely redundant.
groutcho
02-11-2009, 11:52 AM
the expression a > 1 is evaluated as a block and its value is replaced by TRUE or FALSE as soon it is evaluated, so
if (a > 1 AND a < 2) then...
is interpreted by the computer as :
if (TRUE AND TRUE) then...
so if you write
if (a > 1 == TRUE AND a < 2 == TRUE) then...
it is like
if (TRUE == TRUE AND TRUE == TRUE) then...
CGTalk Moderation
02-11-2009, 11:52 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.