/
Template Scripts to Replace Repetitive Authoring

Template Scripts to Replace Repetitive Authoring

Overview

This article describes how to use a template script to replace repeated sections of a script. In many training scenarios, the same set of actions will happen multiple times with slight variations.

This video will show a simple example of how to use a template script to reduce the amount of authoring in these situations.

The steps below follow those in the video.

Storyflow

Here is a script called Identify Tools. It presents a screen message with instructions to identify a hammer, when closed the user can select the hammer. When the hammer is selected a notification message appears. Then this same pattern happens again to identify the jigsaw.

Let's run it and see what it looks like in the headset. This script is launched from the director script which is connected to the Identify the Tools scenario.

Unity / Headset

  • (video shows the the Identify the Tools scenario running)

Storyflow

  • Open the Identify Tools script and compare the Instructions for the Hammer and Instructions for the Jigsaw frames and child frames.

  • Notice the following are different:

    • The messages in the instructions

    • The objects selected

    • The notification messages

  • The following are the same:

    • The flow

    • The resources used

Let's create a template script to replace the repetitive sections.

  • Create a new script called Identify Tools with Instructions Template and open it.

  • Rename the frame Instructions.

  • Add a Playable Content -> Screen Message and enter Instructions in the Title field.

  • Click the dynamic symbol next to the Text field.

  • Click the '+' button next to the field. If you want, you can change the variable name.

  • Click the checkmark.

  • Save the script.

  • Click the '+' button at the bottom of the Screen Message resource and select close.

  • Rename the new frame Select Tool. Add a Select resource.

  • Click the dynamic symbol next to the World Objects field.

  • Click the '+' button next to the World Object field.

  • Rename the variable Tool to Identify.

  • Click the checkmark.

  • Save the script.

  • Click the '+' button at the bottom of the Select resource and select complete.

  • Rename the new frame Identified Correctly Notification.

  • Add a Notification resource.

  • Click the dynamic symbol next to the Message field.

  • Click the '+' button next to the Message field. Rename the variable if you'd like.

  • Click the checkmark.

  • Save the script.

  • Click the '+' button at the bottom of the Notification resource and select complete.

  • Rename the new frame End Script.

  • Add an End Script resource.

  • On the right hand side, select the Variables column.

  • Click the three dots next to the first variable and select Edit.

  • Check the isInput box.

  • Repeat the same steps for the other two variables.

  • Save the script.

The template script is ready at this point.

The template script has the same resources as the old script but allows for variations because of the variables. Let's reconfigure the old script to use the template script.

  • Open the Identify Tools script.

  • Deactivate the Instructions for the Hammer frame and the Instructions for Jigsaw frame.

    • Notice that their child frames are also deactivated. None of them will run at this point.

  • Add a new frame off of the Main Frame.

  • Name it Identify Hammer.

  • In Identify Hammer frame, add a Launch New Script resource and select the Identify Tools with Instructions Template script.

  • Enter in the Instructions Text for the hammer, select the Tool to Identify and add a Notification Message.

  • Click the '+' button at the bottom of the Launch New Script resource and select complete.

  • Rename the new frame Identify Jigsaw. You can change the frame level if you wish.

  • Add a Launch New Script resource and select the Identify Tools with Instructions Template script.

  • Enter in the Instructions Text for the jigsaw, select the Tool to Identify and add a Notification Message.

  • Save the script.

The repetitive sections have been deactivated and replaced with frames using the template script. Run it in the headset.

Unity / Headset

  • The results are the same as the previous run but the scenario now uses the template script.

Conclusion

At this point, you can safely delete the deactivated frames in the script after this successful test. Imagine if you had 20 items to identify.

Template scripts will help make common tasks easier, reduce errors and save authoring time.

 

Related content

Basic Template Script: A Walkthrough
Basic Template Script: A Walkthrough
More like this
Template Scripts: An Overview
Template Scripts: An Overview
More like this
Director Scripts: An Overview
Director Scripts: An Overview
More like this
Your First Look at the Storyflow Script Editor Guide
Your First Look at the Storyflow Script Editor Guide
More like this
Create a Script Catalog
Create a Script Catalog
More like this
Authoring Example: How to Create a Checklist in a Scenario
Authoring Example: How to Create a Checklist in a Scenario
More like this