2009
■ They can use MAXScript global variables to communicate and coordinate
with other controllers and scripts in the software.
Refer to the MAXScript Reference for a complete explanation of this scripting
language.
Writing Controller Scripts
3ds Max interprets the text you type into the Script text box as the body of a
MAXScript block expression. You can type as many expressions as you want
on as many lines as you want, and they are evaluated in turn. The value of
the last expression is taken as the controller value. This value must yield the
right type for the controller: Float for float, Point3 for position, Quat for
rotation, and so on.
Because the text is inside a block expression, you can declare local variables
that are visible only within the script and are temporary for one evaluation.
You can also declare or access global variables that are shared with all other
scripts in MAXScript and hold their values from one evaluation to the next.
A controller is always evaluated by 3ds Max with respect to a specific animation
time. This might be the current time slider or incrementing frame time if an
animation is playing, or a rendering is under way. In the case of Script
controllers, the time being evaluated is used to establish an automatic "at
time" context around the controller script, so any properties you access (outside
of other explicit “at time” expressions) yield the correct values for the current
controller evaluation time. This means you don't have to do anything special
in your scripts to work at the correct time. You can access the evaluation time
with the standard MAXScript variable, currentTime. You can also reference
scene property values at other times by using "at time" expressions in your
scripts, as in regular MAXScript programming.
Assign Nodes and Tracks to Variables
When you need to refer to nodes in your scene or to animation tracks, it is
recommended that you use the Script controller variable toolset to create
variables to assign to any particular node or controller track. This way, if you
decide to later on rename your scene objects, the script controllers using these
objects are preserved because the variables maintain the link to the nodes.
Otherwise, if you assign, for example, a node to a variable manually in the
dialog's Expression window, that link becomes broken as soon as you rename
that particular node.
Script Controller | 3249