<script> ‐ A node script
This element is used to contain a script associated with a scene node. It consists of list of commands made of a trigger, an action, and a target (see Section 2.4).
This element expects a list of commands as content.
In the example below, the script contains three commands. The first two commands are triggered by the reception of the message labeled start if the node is in the state rotatable. The third command is scheduled to be triggered repeatedly from time 100.0 with a period randomly chosen in the interval [0.0..20.0], and a multiplicative ratio of 0.98. The action associated with the first two commands sets a schedule begin time at current time. The target of the first command is the first schedule element in node(s) named interpolator cylinder rotation. The action associated with the third command sets a sound begin time at current time. Its target is the sound element in node(s) named sound explosion 2.
<script id="script_cylinder_translation"> <command> <trigger type="message_event" value="start rotate" state="rotatable" bool_operator="==" /> <action> <set_schedule_attribute_value index="1" operator="="> <schedule begin="now" /> </set_schedule_attribute_value> <target type="multiple_nodes" value="#interpolator cylinder rotation" /> </action> <action> <set_schedule_attribute_value index="1" operator="="> <schedule begin="now" /> </set_schedule_attribute_value> <target type="multiple_nodes" value="#interpolator cylinder translation" /> </action> </command> <command> <trigger type="varying_random_cyclic_time" begin="100" period="20" variation="0.98" /> <action> <set_sound_attribute_value operator="="> <sound begin="now" end="100000" /> </set_sound_attribute_value> <target type="multiple_nodes" value="#sound explosion 2" /> </action> </command> </script>