Page 1225 - Kitab3DsMax
P. 1225
Chapter 49: Automating with MAXScript
-- equal to 4, so true
2 + 2 == 5 -- 4 is NOT equal to 5, so false
3 * 3 == 5 + 4 -- 9 IS equal to 9, so true
3 * 3 != 5 + 4 -- ‘!=‘ means ‘not equal to’. ‘9 is not
-- equal to 9’ is a false statement, so
-- the expression is false
a = 23 -- store 23 in variable a
b = 14 + 9 -- store 23 in variable b
a == b -- 23 IS equal to 23, so true
Play around with simple expressions until you’re familiar with what they mean and have an intuitive feel for
whether or not an expression is going to evaluate to true or false.
Complex expressions
Sometimes you need an expression to decide on more than just two pieces of data. MAXScript has the and,
or, and not operators to help you do this.
FIGURE 49.14
Using the MAXScript Listener to evaluate expressions
The and operator combines two expressions and asks the question, “Are both expressions true?” If both are
true, then the entire expression evaluates to true. But if either is false, or if they are both false, then the
entire expression is false. You can use parentheses to group expressions, so an expression with the and
operator might look something like this:
(1 < 2) and (1 < 3) -- true because (1 < 2) is true AND
-- (1 < 3) is true
1177