End Script Resource
For an overview of Resources, click here.
Deep Learning on Resources is found in Motive Academy. Click here to see the course this lesson is in.
Overview
The End Script Resource terminates the Script. This can be used to prevent a Script from progressing further.
Options for When a Script Finishes
In most training Scenarios, more than one Script is used. Understanding what happens when a Script finishes running is important because it can have an impact on other Scripts that run in the Scenario.
At the end of the day, there are two main choices and an option associated with each one.
The Script Persists
A Script will continue to run if it is not explicitly ended. This means that the Script does not contain an End Script Resource. If all of the Frames have completed, the Script can remain open.
When a Script is open, the Resources remain active. For a closed Screen Message or similar, this doesn’t mean much. However, Resources used to set certain properties, spawn assets, or bind scene objects to behaviour models will remain active. If the Script is ended, those property changes will be reverted, the spawned assets will disappear and any behaviour model bindings will be undone.
Generally, if a Script uses Spawn Asset or Behaviour Model Resources, you want the Script to persist. Setup Scripts are a good example of a Script that should persist. They are designed to prepare the Scenario and settings for other Scripts.
The Script Closes
A Script that closes contains an End Script Resource. This means all Frames in the Script will be deactivated.
Defined Ending Points
Having a defined endpoint for a Script helps to make it reusable and modular. There are two ways to have a defined endpoint. Use an End Script Resource or use a Custom Event.
Required Fields
Field Name | Description |
---|---|
Status | Specifies the Event emitted from this Resource. This will fire |
Events
This will fire Success/Fail on any "Launch New Scripts" Resources that launched this Script. It lets you manage the control flow from Director Scripts essentially. It is not necessary to use these Event Status options, but if you choose to, here is an overview:
You can see in the above example that:
A Script is launched within a Script.
In the second Script, a Multiple Choice Resource is used. This resource associated a “Success” event with getting the question correct and a “Fail” event with getting the question incorrect.
There are two child Frames under the Multiple Choice Resource, representing the branches for Success and Fail. Both of them have an End Script Resource in them with the appropriate Status chosen from the down.
In the original Script, there are two branch Frames. In the Condition area, the Success or Fail of the Launch Script Resource (in Step 1) is added. When the Condition is met, the Resources in this Frame will fire.
Example
This resource is used often to, as mentioned, terminate the current Script.
At the end of any Script, add the End Script Resource in with a Condition that triggers it (so that it doesn’t End prematurely):
Keep in mind that most Resources will also shut down once the End Script Resource is used.