Beth Cataldo, May 1, 2007


Assignment #13 - Creating Scripts


The goal is to create a two different scripts. You should use them with the Marine Mammal Center tracks that you created when you did the Track and Story assignment a few weeks back.

Jumping to a Menu's Loop Point:
This first script will jump to the loop point in the main menu, bypassing the first part of the menu. You should set a loop point in the motion menu before you write the script to make sure that it's working. You should also name your main menu "Main menu" to make this script work.

1. Open the project that you created for the Track and Story Assignment (#9), which you should have a copy of on your hard drive.

2. Add a script to the project.

3. Double click the new script to open up the Script Editor.

4. In the Inspector, name the script Jump to Loop Point.

5. In the Script Editor, select the first line of code (NOP). The Script Inspector should appear.

6. In the Script Command Inspector, choose Jump as the command.

7. Choose Menus>Main Menu> [Menu] from the Jump To pop-up window.

8. Select the Start At Loop Point checkbox.

6. Simulate to see if this works.

You can put this script anywhere that it would jump back to the main menu. For this exercise, attach it to the four tracks where you were jumping back to the main menu.

Randomly Playing Tracks

For this script, we'll use the same project. It should have four tracks. The script will randomly choose one track to play once a menu times out after it has been active for a set amount of time.

To create a Random Play script:

1. Create a new script.

2. Double click on the script to open it. The Script Editor opens and the Script Inspector appears.

3. In the Inspector, name the script Random Play.

4. In the Script Editor, select the first command line (NOP).

The Script Command Inspector appears

5. In the Script Command Inspector, choose Set GPRM as the command.

6. The configure the set GPRM command:

* Choose "ran" as the Operation (for random)
* Choose Immediate as the Source Type
* Enter 4 as the Source Value
* Choose GPRM 0 as the Target

The above settings will generate a random number between 1 and 4 and place the value in GRPM 0. It is this value that will be looked at by the next commands in the script to determine which track to play.

7. In the Script Editor, click the Add button. Another command line should be added to the Script.

8. In the Script Command Inspector, choose Jump as the command.

9. To configure the jump command, choose Tracks and Stories>Fishschool from the Jump To pop-up menu. This plays the first of the four tracks, depending on the result of the compare function added next.

10. Add a compare function to the jump command to test to see if this track has been selected with the random generator.

* Select the Compare Command checkbox
* Choose GPRM 0 as the "Execute if" element to be compared to
* Choose equal (=) as the "is" compare operation type
* Choose Immediate as the "to" element type to compare
* Enter 1 a the "with value"

What this says is: If GRPM 0 has a 1 in it (this 1 was generated by the random number generator command), this jump occurs. If not, the script moves to the next command.

11. Add three additional jump lines -- one for each of the additional tracks. The only differences are the Jump To settings which need to match each different track and the immediate values in the compare function's "with value" field (use 2 for the next track, 3 for the following track and 4 for the final track).

12. You need to configure the menu's timeout setting by selecting the menu in the and then clicking the General tab in the Menu Inspector. Choose Timeout from the At End pop-up menu and enter a value (in seconds) for the timeout. Choose this script (Random Play) from the Action pop-up menu.

What this does: Each time this menu sits idle for the specified amount of time, the script starts, generates a random number and then plays one of the four tracks. Once the track ends, it will jump to the asset specified by its End Jump setting.