2009

The opening section contains "fn" (function) followed by the function name,
which also must appear in the State Transition dialog, and then the input
parameters "del t", and lastly "= (". Following this there can be any MAXScript
code, or none.
The closing section contains a necessary MAXScript conditional, and then
"then 1 else 0". This means: If the result of the conditional is true, then return
1 (that is, the transition is to take place), or if the result of the conditional is
false, then return 0 (that is, the transition is not to take place). You could
reverse the order of the numbers 1 and 0 ("then 0 else 1") so that the
conditional being true would cause no transition to take place, and vice-versa.
Lastly, the function must end with a close parenthesis: ")".
Following are some examples of scripts that can be used in cognitive
controllers, along with brief explanations. These are presented for you to
modify and use in your own scenes.
NOTE See this topic in the online User Reference for sample code to test an object
position, test the distance between two objects, and test a modifier parameter.
Testing a Particle System Parameter
This sample script tests the number of particles emitted by particle system
Spray01, and returns positive if the number equals 100.
fn TestParticles del t = (
if (particleCount $Spray01) == 100
then 1 else 0 )
Testing an Atmospheric Property
This sample script tests the Density parameter of a fog effect, and returns
positive if it equals 50.
fn TestAtmos del t = (
atmos_fog = getAtmospheric 1
print atmos_fog.density -- to:debug
if (atmos_fog.density == 50)
then 1 else 0 )
Note the second line, which assigns the fog atmospheric to a variable named
"atmos_fog". This is necessary only for atmospheric effects; with most standard
objects, you simply use the object name preceded by a $, as in the two previous
examples. The "1" following the getAtmospheric command refers to the
atmospheric's position in the Rendering Effects dialog > Effects list.
4862 | Chapter 17 character studio