Scripting Examples

By their nature, scripts tend to be very project-specific. While the function of a particular script might apply to a wide variety of projects, the specific tracks, streams, and menus it works with vary.

The following examples provide you with step-by-step instructions that can help you understand the process of creating a script, from the initial concept to the final product. These scripts show just one way to accomplish their tasks—alternate ways to accomplish the same results often exist.

Note: These examples use menu and track names that are fictitious. You can create these elements and add suitable assets to them, or adapt these examples to your existing assets. You can even create these as empty elements, with no assets assigned. It is the names of the elements that get used in these script examples, not the actual assets. Additionally, these examples assume you have not partitioned the GPRMs.

Jumping to a Menu’s Loop Point

For this script, the project has a motion menu that has a loop point set, and you want to be able to have other elements jump directly to the loop point, bypassing the first part of the menu’s video.

For this script, you’ll call the menu Main Menu.

To create a Jump to Loop Point script
  1. Do one of the following:

    • Choose Project > Add to Project > Script, or press Command–Single Quote (’).

    • Click Add Script in the toolbar.

  2. Double-click the new script in the Outline or Graphical tab.

    The Script Editor opens and the Script Inspector appears.

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

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

    The Script Command Inspector appears.

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

  6. Choose Menus > Main Menu > [Menu] from the Jump To pop-up menu.

  7. Select the Start At Loop Point checkbox.

You can use this script anyplace where you might normally jump to the Main Menu. For example, you could set a track’s End Jump to run this script—when the track finishes playing, it jumps to the Main Menu’s loop point.

Randomly Playing Tracks

For this script, the project has four tracks, and you want a script to randomly choose one to play once a menu times out (has been inactive for a set amount of time).

For this script, you’ll call the tracks “Ocean,” “Beach,” “Trail,” and “Shopping.”

To create a Random Play script
  1. Do one of the following:

    • Choose Project > Add to Project > Script, or press Command–Single Quote (’).

    • Click Add Script in the toolbar.

  2. Double-click the new script in the Outline or Graphical tab.

    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. To configure the set GPRM command:

    1. Choose “ran” as the Operation.

    2. Choose Immediate as the Source Type.

    3. Enter 4 as the Source Value.

    4. Choose GPRM 0 as the Target.

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

  7. In the Script Editor, click the Add button.

    The next command line is 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 > Ocean > Marker 1 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.

    Note: Remember that the Ocean track is fictitious. Unless you created a track called Ocean, you won’t see it in this pop-up menu.

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

    1. Select the Compare Command checkbox.

    2. Choose GPRM 0 as the “Execute if” element to be compared to.

    3. Choose equal (=) as the “is” compare operation type.

    4. Choose Immediate as the “to” element type to compare.

    5. Enter 1 as the “with value.”

    If GPRM 0 has a 1 in it (generated by the random number generator command), this jump command occurs. If not, the script moves to the next command.

  11. Add three additional jump command lines—one for each of the other three fictitious tracks. The only differences are the Jump To settings which need to match each track (Tracks and Stories > Beach > Marker 1; Tracks and Stories > Trail > Marker 1; and Tracks and Stories > Shopping > Marker 1) and the immediate values in the compare function’s “with value” field (use 2 for the Beach track, 3 for the Trail track, and 4 for the Shopping track).

    Figure. Script Editor showing the commands for the randomly playing tracks example script.
  12. You need to configure the menu’s timeout setting by selecting the menu in the Outline or Graphical tab, 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.

Each time the 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 jumps to the element specified by its End Jump setting.

Playing All Tracks

For this script, the project has four tracks, each with a button on the main menu to start it playing. You want to add a Play All button that will play all four tracks in order, returning to the main menu once they have finished. In this case, you will create five scripts—one that starts the Play All progress and one for each track that determines whether a Play All function is active.

The Play All script places a value in a GPRM that indicates to the other scripts that a Play All function is in process. It then jumps to the first track and starts it playing.

The other scripts are linked to each track’s End Jump settings. These scripts test to see if the Play All function is active. If it is, the script jumps to the next track. If not, the script jumps back to the main menu.

For this script, you’ll call the tracks “Ocean,” “Beach,” “Trail,” and “Shopping.”

The Play All Script

This is the script you will link to the main menu’s Play All button.

To create the Play All script
  1. Do one of the following:

    • Choose Project > Add to Project > Script, or press Command–Single Quote (’).

    • Click Add Script in the toolbar.

  2. Double-click the new script in the Outline or Graphical tab.

    The Script Editor opens and the Script Inspector appears.

  3. In the Script Inspector, name the script Play All.

  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. To configure the set GPRM command:

    1. Choose “mov” as the Operation.

    2. Choose Immediate as the Source Type.

    3. Enter 1 as the Source Value.

    4. Choose GPRM 0 as the Target.

    The above settings place the value 1 in GPRM 0. It is this value that is looked at by the other scripts to determine whether a Play All function is in progress.

  7. In the Script Editor, click the Add button.

    A second command line is 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 > Ocean > Marker 1 from the Jump To pop-up menu.

    This plays the first of the four tracks.

Figure. Script Editor showing the play all example script commands.

Note: Remember that the Ocean track is fictitious. Unless you created a track called “Ocean,” you won’t see it in this pop-up menu.

Link this script to the main menu’s Play All button. See Setting a Button’s Connection for more information.

The Track End Scripts for the First Three Tracks

The scripts you will link to the End Jump settings of the first three tracks are nearly identical—the only difference is the track name they jump to if a Play All function is in progress. The script used by the last track is a bit different, because it resets the GPRM that indicates a Play All function is in progress and always jumps to the main menu.

Follow these steps to create the script for the first track (Ocean). The notes indicate any changes you would enter for the other tracks (Beach and Trail). Remember these track names are fictitious, and you won’t actually see them in the pop-up menu unless you create them.

To create the script for the first three tracks
  1. Create a script and select it.

  2. Enter Ocean End as the script’s name.

    Note: Enter Beach End and Trail End as the names when creating the scripts for the other two tracks.

  3. In the Script Editor, select the first command line (Nop).

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

  5. To configure the jump command, choose Tracks and Stories > Beach > Marker 1 from the Jump To pop-up menu.

    Note: Choose Tracks and Stories > Trail > Marker 1 and Tracks and Stories > Shopping > Marker 1 when creating the scripts for the other two tracks.

  6. Add a compare function to the jump command to test to see if a Play All function is in process.

    1. Select the Compare Command checkbox.

    2. Choose GPRM 0 as the “Execute if” element to be compared to.

    3. Choose equal (=) as the “is” compare operation type.

    4. Choose Immediate as the “to” element type to compare.

    5. Enter 1 as the “with value.”

    If GPRM 0 has a 1 in it (indicating the Play All function is in progress), this jump command occurs. If not, the script moves to the next command line.

  7. In the Script Editor, click the Add button.

    The next command line (Nop) is added to the script.

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

  9. To configure the jump command, choose Menus > Main Menu > Button 1 from the Jump To pop-up menu.

Like the track names, Button 1 is fictitious, used to illustrate the example.

This jump only occurs if the compare function was not satisfied in the previous command.

Figure. Script Editor showing the commands for the track end script for the first track, Ocean.
Figure. Script Editor showing the commands for the track end script for the second track, Beach.
Figure. Script Editor showing the commands for the track end script for the third track, Trail.

Once you have created all three scripts, link each to the appropriate track’s End Jump setting (at the top of the Track Inspector for each track).

Track End Script for the Last Track

Follow these steps to create the script for the last track (Shopping). The main menu always appears when this track finishes playing—the difference is that the GPRM value needs to be set back to 0 so that a Play All process does not inadvertently get started later.

To create the Track End script for the last track
  1. Create a script and select it.

  2. Enter Shopping End as the script’s name.

  3. In the Script Editor, select the first command line (Nop).

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

  5. To configure the set GPRM command:

    1. Choose “mov” as the Operation.

    2. Choose Immediate as the Source Type.

    3. Enter 0 as the Source Value.

    4. Choose GPRM 0 as the Target.

    The above settings place the value 0 in GPRM 0, ending the Play All process and ensuring that if you play any of the tracks individually, they will jump back to the main menu when finished playing.

  6. In the Script Editor, click the Add button.

    The next command line (Nop) is added to the script.

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

  8. To configure the jump command, choose Menus > Main Menu > Button 1 from the Jump To pop-up menu.

This script always sets GPRM 0 to 0 and jumps back to the main menu. Link this script to the Shopping track’s End Jump setting, located at the top of its Track Inspector.

Figure. Script Editor showing the commands for the track end script for the last track, Shopping.

But What If...

When you create scripts that store a status in a GPRM, such as the Play All script, you need to plan for Viewer actions that are outside of the script’s intentions. In this case, these scripts will work exactly as intended most of the time. An exception is if the viewer decides not to let the Play All process finish. The viewer might press the Menu button on the remote control while the Play All process is active and then choose a specific track to watch by selecting its button in the menu. Because the value in GPRM 0 is still “1,” once that track finishes playing and runs its Track End script, it will see that GPRM 0 is “1” and jump to the next track instead of back to the menu.

In other words, the only way to really stop the Play All process and reset GPRM 0 to “0” with the previous scripts is to let the process play to the end. There are a couple of ways to handle this:

  • Force the viewer to watch to the end: You can disable the Menu and Title buttons on the remote control. This may be appropriate for training videos with mandatory viewing. See Remote Control Settings for more information.
  • Add scripts to the other menu buttons that reset GPRM 0 to “0”: This way, if the viewer chooses to play one of the tracks on its own, the Play All process will be canceled and, once the track finishes playing, the DVD will jump back to the menu. See Canceling the Play All Script for more information.

Canceling the Play All Script

The script required to cancel the Play All script is almost identical to the Play All script—the differences are that you set GPRM 0 to “0” instead of “1,” and the jump target is set to match what the button would have jumped to.

For example, if the menu with the Play All button also has buttons for each individual track (“Ocean,” “Beach,” “Trail,” and “Shopping”), you will need to create a unique script for each of these buttons that sets GPRM 0 to “0” and then jumps to the button’s track.

Use the steps in The Play All Script to create these scripts, with the following modifications:

  • Name the scripts “Ocean Play,” “Beach Play,” and so on in step 3.

  • Enter 0 as the Source Value in step 6.

  • Configure the jump command in step 9 exactly as listed for the Ocean track. The scripts for the other three tracks only need this step changed, with each configured to jump their track.

Once the four scripts have been created, you link them to the menu buttons.