Friday, November 19, 2010

3ds max: MAXScript basics

comments:
-- single line comment
/* multi-line comment */

variables. simple. no need to declare. eg.: a = 3

F11 - Script listener. something like Output panel in flash. but it allows u to key in scripts directly

(.) dot operator = object properties
($) superscript = can use it to reference an object using pathname. eg.: $Sphere01.

point3 data type
eg.:


newpos = point3 10 0 0
b.pos = newpos
function parameter in any order
FunctionName keyword1:value1 keyword2:value2

5 /9 = 0. so if need decimal place, must use 5.0/9 or 5 / 9.0 or 5.0 / 9.0

custom function:
function celsiusToFahrenheit celsius =
(
fah = 5.0/9 * (celsius - 32)
return fah
)

returns fah automatically if without 'return fah'

pass by value default
pass by reference using (&) symbol

if-then-else
eg.:
if(zz > 100) then messagebox "hot"


example 2
function testIF a=
(
if(a > 0) then
(
messagebox "more than zero"
)
else if(a == 0) then
(
messagebox "equal to zero"
)
else
(
messagebox "less than zero"
)
)
and, or operator. literally use "and" and "or"

for loop
eg.:
function testFor a=
(
for i=1 to a do
(
b = box()
b.pos.x = i * 10
)
)


do-while loop
do
(
statements(s)
)
while(conditions)

while-do loop
while(conditions) do
(
statement(s)
)

No comments: