Scripting - Objects - ScriptEvents

Updated 7 months ago

'Script events' define the logic that is run when a 'game event' occurs.

Common Properties

All types of script events have the variables listed:

comment

Text that explains what the event does.
Value: Any valid string (e.g. "This is a script event")
(Optional)

scriptEventType

The type of script event, it defines which script event it is.
Values: Any of the types listed under the heading "Script Event Types", as a string (e.g. "PlayMusic")

gameEventType

The type of game event to listen to.
Values:

  • "FrameUpdated" - Runs when a new frame is drawn.
  • "ShipLanded" - Runs when the ship fully lands (when the clock reaches the top of the screen).
  • "ShipTakeOff" - Runs when the ship takes off.
  • "ShipLeavingAlertCalled" - Runs when the ship leaving alert is called.
  • "PlayerDamaged" - Runs when the player you're controlling takes damage.
  • "PlayerDied" - Runs when the player you're controlling dies.
  • "PlayerEnteredFacility" - Runs when the player you're controlling enters the facility.
  • "PlayerExitedFacility" - Runs when the player you're controlling exits the facility.
  • "PlayerEnteredShip" - Runs when the player you're controlling enters the ship.
  • "PlayerExitedShip" - Runs when the player you're controlling exits the ship.
  • "ApparatusTaken" - Runs when someone takes the Apparatus out of the wall.
  • "CurrentMoonChanged" - Runs when the current moon is changed at the terminal.

conditions

The conditions to check before running the event, all conditions have to pass for the event to run.
Value: An array of Conditions.
(Optional)

Script Event Types

PlayMusic

Defines when and how music should play.

loop

Should the music loop?
Values: true, false
Default: false

silenceGameMusic

Should the music stop the game's default music?
Values: true, false
Default: true

overlapHandling

How the event should handle if music is already playing.
Values:

  • "IgnoreAll" - Ignore this event if any music is already playing.
  • "IgnoreTag" - Ignore this event if music with the same tag is already playing.
  • "OverrideAll" - Instantly stop all the music and start this event's music.
  • "OverrideTag" - Instantly stop all the music with the same tag and start this event's music.
  • "OverrideFadeAll" - Stop all the music by fading it out and start this event's music.
  • "OverrideFadeTag" - Stop all the music with the same tag by fading it out and start this event's music.
  • "Overlap" - Play this event's music at the same time as anything else.

tag

The tag to give the music, this can be used for complex logic and grouping.
Value: A valid string. (e.g. "EscapeMusic")
(Optional)

musicNames

The list of music to randomly pick to play. (The file name and extension, e.g. "SomeMusic.ogg". Not including the file extension will make it default to WAV)
Value: An array of strings.

Example: a PlayMusic event that plays random music out of two options when the ship leaving alert is called

{
    "comment": "The music that plays when the early leave alert is called",
    "scriptEventType": "PlayMusic",
    "gameEventType": "ShipLeavingAlertCalled",
    "conditions": [],
    "overlapHandling": "IgnoreTag",
    "tag": "EscapeMusic",
    "musicNames": [
        "ItsPizzaTime.ogg",
        "TheDeathThatIDeservioli.ogg"
    ]
}

Example: a more complex PlayMusic event that only plays if the weather is either of two options using an Or Condition, using the same event type as the previous example

{
    "comment": "The music that plays during heavy weather when the early leave alert is called",
    "scriptEventType": "PlayMusic",
    "gameEventType": "ShipLeavingAlertCalled",
    "conditions": [
        {
            "conditionType": "Or",
            "conditions": [
                {
                    "conditionType": "Weather",
                    "weather": "Eclipsed"
                },
                {
                    "conditionType": "Weather",
                    "weather": "Stormy"
                }
            ]
        }
    ],
    "overlapHandling": "IgnoreTag",
    "tag": "EscapeMusic",
    "musicNames": [
        "ThousandMarch.ogg"
    ]
}

StopMusic

Defines when music should stop.

targetTags

The tags to target, only music with these tags will stop. Do not include if you want to stop all music.
Value: An array of strings.
(Optional)

instant

Should the music stop instantly, or should it fade out?.
Default: false

Example: a StopMusic event that fades out the music when the ship leaves

{
    "comment": "Stops the escape music when the ship takes off",
    "scriptEventType": "StopMusic",
    "gameEventType": "ShipTakeOff",
    "targetTags": [
        "EscapeMusic"
    ]
}

ResetTimers

Defines when timers should be reset. (See the Timer condition for more information about timers)

targetTimerNames

The timers to target, only the specified timers will reset. Do not include this variable if you want to reset all timers.
Value: An array of strings.
(Optional)

Example: a ResetTimers event that resets a timer that tracks how long it's been since the player was last damaged

{
    "comment": "Resets a timer when the player is damaged",
    "scriptEventType": "ResetTimers",
    "gameEventType": "PlayerDamaged",
    "targetTimerNames": [
        "TimeSinceLastDamaged"
    ]
}

SetVolumeGroupMasterVolume

Defines when the master volume of a volume group should be set and what it should be set to

targetTags

The volume groups/music tag to target. Leaving out this variable will set the master volume of the default volume group.
Value: An array of strings.
(Optional)

masterVolume

The volume to set the target volume group's master volume to.
Value: A valid float.\

Example: a SetVolumeGroupMasterVolume event that sets the volume of a volume group when the player leaves the facility

{
    "comment": "Sets the master volume of a volume group to 1 when you leave the facility",
    "scriptEventType": "SetVolumeGroupMasterVolume",
    "gameEventType": "PlayerExitedFacility",
    "targetTags": [
        "DangerousMusic"
    ],
    "masterVolume": 1
}