Scripting - Objects - Script

Updated a year ago

Script

A Script is a JSON file that defines the logic behind how the mod plays music.
Scripts use the JSON data format, so you will need to be familiar with JSON's syntax to create new scripts. I suggest that you enable the console under "Console.Logging" in BepInEx's config if you want to debug your scripts. You can also read the game's logs after closing the game at this file path: %USERPROFILE%\AppData\LocalLow\ZeekerssRBLX\Lethal Company\Player.log

comment

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

isAddon

If set to true, this script will be combined with other loaded addon scripts into one big script and will share volume groups, timers, tags, and other script specific things. Addon scripts can be unstable and are prone to breaking. If set to false the script will be individual and will share nothing with other scripts.
Value: true, false
Default: false

volumeGroups

The volume groups in the script, volume groups control the volume of the music. Having no volume groups defaults all volume to 1.
Value: An array of VolumeGroups.
(Optional)

scriptEvents

The events in the script.
Value: An array of ScriptEvents.

Example: a script with no events, and no volume groups

{
    "volumeGroups": [],
    "scriptEvents": []
}

Example: a script with three events, and a volume group

The volume group in this example halves the volume when the player is crouching

{
    "volumeGroups": [
        {
            "tag": "EscapeMusic",
            "volumeLerpSpeed": 2,
            "stoppingVolumeLerpSpeed": 0.5,
            "volumeModifiers": [
                {
                    "comment": "Crouching volume scale",
                    "volumeScale": 0.5,
                    "condition": {
                        "conditionType": "PlayerCrouching"
                    }
                }
            ]
        }
    ],
    "scriptEvents": [
        {
            "comment": "The music that plays when you're inside the facility when the early leave alert is called",
            "scriptEventType": "PlayMusic",
            "gameEventType": "ShipLeavingAlertCalled",
            "conditions": [
                {
                    "conditionType": "PlayerLocation",
                    "location": "Facility"
                }
            ],
            "overlapHandling": "IgnoreTag",
            "tag": "EscapeMusic",
            "musicNames": [
                "ByeByeThere"
            ]
        },
        {
            "comment": "The music that plays when the early leave alert is called",
            "scriptEventType": "PlayMusic",
            "gameEventType": "ShipLeavingAlertCalled",
            "conditions": [],
            "overlapHandling": "IgnoreTag",
            "tag": "EscapeMusic",
            "musicNames": [
                "ItsPizzaTime",
                "TheDeathThatIDeservioli"
            ]
        },
        {
            "comment": "Stops the escape music when the ship takes off",
            "scriptEventType": "StopMusic",
            "gameEventType": "ShipTakeOff",
            "conditions": [],
            "targetTags": [
                "EscapeMusic"
            ]
        }
    ]
}