GENERATE/PREV.gifGENERATE/NEXT.gif

Math Assignment

MAXScript provides the C language shorthand form of assignment that can be used for modifying a value in place, as happens the following long-form examples:

x = x + 1

$obj.pos = $obj.pos * scale

Corresponding to the four math operations +, -, *, and /, are assignment operators that apply the operation to the assignment's destination and update the destination with the result. Their syntax is:

<destination> += <expr>      -- add <expr> to destination

<destination> -= <expr>      -- subtract <expr> from destination

<destination> *= <expr>      -- multiply destination with <expr>

<destination> /= <expr>      -- divide destination by <expr>

Using the shorthand form of assignment, the above examples can be written as:

x += 1      -- increment x by one

$obj.pos *= scale      -- multiply $obj.pos with scale