Use a condition to control the flow of frames in a script
In this tutorial, we will learn about Conditions and use a Notification Resource. To prepare, review these resources:
In our last tutorial, we added a Welcome Message that the user clicks "ok" on the screen to clear. Now, let's create a notification, with a sound, to say "Scenario has started".
Step 1: Create a New Subframe
- Open the "Welcome Message" script. You can do this by clicking on the tab at the top of the editor:
Or, if you have closed the "Welcome Message" script, you can find it by clicking on the scroll icon on the right-hand side of the screen and choosing it from your script catalog.
- Once your "Welcome Message" script is open, add a subframe to the script by clicking on the '+' on the "Welcome Message" frame.
- Re-name this frame "Notification".
- Click outside the text box to save:
Step 2: Add a Notification Resource
- Search the Resources for a "Notification".
- Drag "Notification" into your frame.
- Add text to the notification in the "Message" area:
Let's add a sound to this notification.
- Click on the '+' beside the "Sound" field.
- The media catalogs will open. Choose the "Sound Effects" catalog.
- Choose the sound that you would like to use. In this example, we chose "Action_Login 01.ogg":
- Finally, let's add an icon to the "image" field using the same process. Click the '+' beside the "Image" field
- Select the "Icons" media catalog.
- Choose an appropriate icon. In this case, we chose the checkmark:
- STOP: Save and test in the headset. When you start the scenario, you will notice that the screen message and the notification try to play at the same time. Let's fix this.
Step 3: Add a Condition
When a frame opens, all of its subframes open and run as well. In order to control the flow of frames, we use conditions. In this case, we want the notification to play after the user has clicked 'ok' on the screen message. When the user clicks 'ok' on the screen message, it "closes". We can create a condition that listens for the "close" of the screen message.
- With the "Notification" frame active, click over to the "Conditions" panel in the editor:
- Use the search bar to look for "Object Event".
- Drag and drop the condition into the top blue condition frame. This allows you to say "when the resource I choose fires a specific event, open this frame".
- To complete the condition, select the "Welcome to the Demo Scenario" script object (this is our screen message).
- Select "Close" as the event:
- STOP: Click save, reset in the headset, and then test. Now, when you start the scenario, the notification will play after you close the screen message.
In the Headset
Here is what your scenario will look like so far:
Key Takeaways from Tutorial 2
- A resource like Notification has many ways to draw the learner's attention. Text, sound, image, and vibrate can all be used together or individually. Be sure to check out the options on each resource you use.
- Conditions are used to control the flow of a frame. A common use is to dictate the order of when items fire in the scenario.