Global Settings: Scripts

Your app will have many scenarios that require no conditional logic. For example, examine door might always return the output, "It's a heavy wooden door." These "vanilla" scenarios can be completely defined within the Scenarios editor, but when you need conditional logic the Scripts editor is the place to start.

The Structure of a Script

You'll want to get familiar with the recursive structure of scripts:

Script Root
  • Actions (all processed before the Tests node)
    • Action 1
    • Action 2
  • Tests
    • Test 1
      • Pass/Fail Result
        • Actions
        • Tests
        • ... etc.
  • End Actions
    • Action 1
    • Action 2

A Simple Example

Here's an example script from the Starter App template. It executes when a character examines the kitchen sink:

Here's a breakdown of what's actually happening:

  • The examine sink scenario (defined in Scenarios editor) triggers the script-examine-sink script.
  • Actions directly under Script Root execute first. In this case, there aren't any.
  • The VisualStateEquals test checks if the visual-sink visual is in the Default (off) state.
  • Based on whether the test passes, the character tells you whether the sink is on or off.

Note that the Pass/Fail results are also containers for additional actions and tests. This recursive structure gives you the power to create flexible, intelligent sequences.

Building a Script

When you open the Scripts editor and add a new script, you'll start with an empty tree. As you click on various nodes of the tree, buttons will appear which allow you add/edit/delete actions, tests, and results.

How Actions and Tests are Processed

When a script is executed, the script engine starts at the Script Root and performs the following steps:

  1. Executes all items in the Actions node directly under Script Root.
  2. Recursively evaluates Tests and executes the Actions under the Pass or Fail result for each test.
  3. Executes all items in the End Actions node directly under Script Root.

Note that if the Exit On Complete option is checked on a Test, no subsequent tests in the script will be evaluated.


Now that you're familiar with the structure, check out the Actions and Tests available to your app:

Script Reference: Actions

Script Reference: Tests

Back to search