Accessing Level Script Data
- Press Escape → Level Properties
- Click the Script button
Configuration
Script Reference
The name of the script in the level’s script collection. This script will be executed as the level’s main script.Script Tag
A string identifier for this level instance. Useful when the same level is used in multiple contexts.Local Variables
Key-value pairs accessible from the level script. These are stored asEditorLevelScriptData and persisted with the level.
How Level Scripts Work
The level script is attached to the level data via:levelData.ScriptRef— The script referencelevelData.ScriptTag— The tag stringlevelData.ScriptVars— The variable collection
OnStart— When the level beginsOnUpdate— Every frameOnLevelEvent— Custom level events
Example
Data Flow
TheEditorLevelScriptData class implements ILuaScriptOwnerInfo, providing:
ScriptReference— Get/set the script referenceLuaTag— Get/set the tag stringLuaLocalVariablesDefinitions— Get/set the variable collection
LevelData object. When loaded, they are restored from the saved data.
Level scripts are separate from element scripts. A level script runs once for the entire level, while element scripts run per-element. Both can coexist.