1. Help Center
  2. Tutorials
  3. Workshop Training Tutorials

Workshop Tutorial 8 - Introduction to Dynamic Variables

Use a dynamic variable to change the volume of the speaker

Quick Links

Step 1: Create a "Speaker" Script

Step 2: Add a Menu Option Resource

Step 3: Add a New Frame with an Audio Resource

Step 4: Create a Volume Variable

Step 5: Add a New Frame that Opens on "Close" of the Menu

Step 6: Add the Newly Created Variable the New Frame

Step 7: Set Using the Dynamic Content Editor

Step 8: Add a Replay

Step 9: Add a Default Volume

Step 10: Launch this Script from the "Ambience" Script

In the Headset

 

Variables are an important and powerful component in the StoryFlow authoring system. Variables allow you to store values to be used later and to change things dynamically as the scenario unfolds. In this example, we will use a simple dynamic variable implementation to allow the learner to control the volume of the music in the workshop.

Step 1: Create a "Speaker" Script

  • Create a new script called "Speaker".
  • Open the new script.
  • Re-name the New Frame "Scene objects".

    • Open the Catalog icon and choose "Workshop Objects".
    • Drag the Speaker object to the frame:
    2021-01-12_11-21-28

    Step 2: Add a Menu Option Resource

    • Create a new frame (from the Main Frame) and add a "Menu Option" resource to it:

    • Under "World Objects", choose "Speaker".
    • Under "Prompts", choose "Text".
    • Add a text prompt that says "Adjust volume". 
    • Under Input Option/Menu Option/Text, enter "Volume Up".
    • Under "Event", choose "Add Custom Event".
    • Enter the text "Volume Up" and select the checkmark to save your Custom Event.
    • Ensure your "Volume Up" event shows in the Event area (use the dropdown to select it).
    • Scroll back up to "Input Options" and click on the "+" icon to add another option.
    • Under the "Input" dropdown, choose "Menu Option".
    • In the text field, enter "Volume Down".
    • Under "Event", choose "Add Custom Event".
    • Enter the text "Volume Down" and select the checkmark to save your Custom Event.
    • Ensure your "Volume Down" event shows in the Event area (use the dropdown to select it).


    Did you get stuck?  Check out this video:

    Menu Item resource

    If the video is too small, mouse over the bottom right and click on the fullscreen icon after you hit play. 

    Screen Shot 2021-01-14 at 12.11.02 PM

    • Re-name this frame "Menu Option".
    • Save your script.

    Step 3: Add a New Frame with an Audio Resource

    • Create a new subframe below the Menu Option frame and re-name it "Audio".
    2021-01-12_11-57-09
    • Click on the Media icon on the far right and choose "Workshop Music".
    2021-01-12_11-58-49
    • Drag the music (Audio Resource) you'd like to use over to the frame.
    • The anchor is the speaker.
    Note, This is a repeat of what we did in the "Add Ambience" tutorial, but we are going to add to it.

    Step 4: Create a Volume Variable

    Instead of setting the volume, we will create a volume variable and allow the learner to control it.

    • Click on the atom icon beside the "Volume" label.
    • Click the '+' to create a new variable.
    • Give it a name and click the checkmark to complete.
    create volume variable

     

    Now, you should see a variable added to your script:

    2021-01-12_12-04-17

    Step 5: Add a New Frame that Opens on "Close" of the Menu

    • Add a frame below the Audio. Make it open on "close" of the menu:

    2021-01-12_12-07-41 

    Step 6: Add the Newly Created Variable to the New Frame

    • Drag the Volume variable into this new frame:

    Step 7: Set Using the Dynamic Content Editor

    • Click the atom icon in the top right corner of the screen to toggle the editor view:

    • Watch this video for an explanation of how to set variables dynamically. 
    how to set dynamic values

    If the video is too small, mouse over the bottom right and click the fullscreen icon after you hit play. 
    Screen Shot 2021-01-14 at 12.11.02 PM

    • Save Script.

    Step 8: Add a Replay

    After the variable is processed we need to replay the Menu frame so that the new volume value takes effect.

    • Toggle editor view back:
    2021-01-12_12-15-25
    • Add a "Replay Frame" resource to this frame (the same frame where you created this dynamic content tree) by dragging it from the Resources area to the frame
    • Choose the Menu Option frame (because that is where the menu option is).

    2021-01-12_12-17-18

    • Remember to toggle "Ignore Previous" on the condition in the replay frame - if you don't you'll end up with an infinite loop!
    • Scroll up to the Object Event condition and check the box.

    Step 9: Add a Default Volume

    You might find the volume of the music too loud by default (before it is controlled by the user).

    • Add a new top-level frame (not a subframe).
    • Re-name the frame "Default Volume".
    • Drag the variable into the frame.
    • Set the default value to the level you'd like to be at the start of the scenario.

    In this tutorial we set it to 0.1:

    2021-02-11_03-46-30

    Step 10: Launch this Script from the "Ambience" Script

    • Open the "Ambience" script.
    • Launch this new volume-controlled speaker from the frame where you had put the audio resource with the speaker music.
    • You can deactivate the audio resource as this new script does the same thing:
    Add new volume script

    If the video is too small mouse over the bottom right and click the fullscreen icon after you hit play. 

    Screen Shot 2021-01-14 at 12.11.02 PM

    • STOP:  Save and test. Now you should be able to control the volume of the speaker with the menu.

    In the Headset

    This is what your scenario will look like so far:

     

    Next Up:  Workshop Tutorial 9 - That's a Wrap