Skip to main content

RideSectionSoundPlugin

Plays a sound when the ride enters a section of the ride indicated by a range in an animation.

This is can be used to setup lift anti-rollback sounds for a coaster, sounds that only play when a coaster train is in a certain section of the ride.

Static Animations are animations where this plugin is ALWAYS enabled.

Setup

-- create MovementSoundPlugin
local movementSoundPlugin = RideMovementSoundPlugin.new(animPlayer, {
	folderName = "MovementSounds",
	soundProperties = {
		-- overwrite properties of Sound
		SoundId = "rbxassetid://0000", -- set sound id here
	},

	useConstantSpeed = true,
	maxSpeed = 10.0,
	minSpeed = 0,

	maxVolume = 1.5,
	minVolume = 0.0,
	maxPitch = 1.0,
	minPitch = 0.5,

	fadeInTime = 2,
	fadeInStyle = Enum.EasingStyle.Quint,
	fadeOutTime = 2,
	fadeOutStyle = Enum.EasingStyle.Quint,
})

-- create section sound plugin
local sectionSoundPlugin = RideSectionSoundPlugin.create(
	movementSoundPlugin,
	rideManager,
	{
		["RideAnimation"] = {
			{
				startTrigger = "Lift_SECTION_START",
				endTrigger = "Lift_SECTION_END",
			}
		}
	}
):unwrap()

Types

SectionRange

interface SectionRange {
startnumber
stopnumber
}

AnimationSectionRanges

type AnimationSectionRanges = {[string]{SectionRange}}

CreateRangeInfo

interface CreateRangeInfo {
startTriggerstring
stopTriggerstring
}

Functions

new

Constructor
RideSectionSoundPlugin.new(
movementSoundPluginRideMovementSoundPlugin,
animationSectionRangesAnimationSectionRanges,
staticAnimations{string}?
) → RideSectionSoundPlugin

Default constructor

extractRangesFromAnimation

Static
RideSectionSoundPlugin.extractRangesFromAnimation() → Result<{SectionRange},string>

Extracts the ranges for an animation.

getSectionRanges

Static
RideSectionSoundPlugin.getSectionRanges(
rideManagerRideManager,
animationList{string},
startTriggerNamestring,
endTriggerNamestring
) → Result<AnimationSectionRanges,string>

Extracts ranges from a map of animations in a RideManager.

create

Constructor
RideSectionSoundPlugin.create(
movementSoundPluginRideMovementSoundPlugin,
rideManagerRideManager,
animationTriggerData{[string]CreateAnimationData}
) → Result<RideSectionSoundPlugin,string>

Types

type CreateAnimationData = CreateRangeInfo | true

Create constructor.

Creates a RideSectionSoundPlugin by extracting ranges from Animation using triggers.

fromRideManager

Constructor
RideSectionSoundPlugin.fromRideManager(
movementSoundPluginRideMovementSoundPlugin,
rideManagerRideManager,
startTriggerNamestring,
endTriggerNamestring,
staticAnimations{string}?
) → Result<RideSectionSoundPlugin,string>

Constructs a RideSectionSoundPlugin by looking through all of the registered animations of the given RideManager and extracting ranges with the given triggers.

This is designed to be a quick and easy constructor.

fromTriggers

Constructor
RideSectionSoundPlugin.fromTriggers(
movementSoundPluginRideMovementSoundPlugin,
rideManagerRideManager,
animationList{string},
startTriggerNamestring,
endTriggerNamestring,
staticAnimations{string}?
) → Result<RideSectionSoundPlugin,string>

Constructs a RideSectionSoundPlugin by extracting ranges using the following triggers

isEnabled

RideSectionSoundPlugin:isEnabled() → boolean

Returns true if this plugin is currently enabled

setIsEnabled

RideSectionSoundPlugin:setIsEnabled(valueboolean) → ()

Sets whether the plugin is enabled or disabled. While disabled, the movement sound will not play.

isInSection

RideSectionSoundPlugin:isInSection() → boolean

Returns true if the animationPlayer is in a section

update

RideSectionSoundPlugin:update() → ()

Updates this plugin

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Default constructor",
            "params": [
                {
                    "name": "movementSoundPlugin",
                    "desc": "",
                    "lua_type": "RideMovementSoundPlugin"
                },
                {
                    "name": "animationSectionRanges",
                    "desc": "",
                    "lua_type": "AnimationSectionRanges"
                },
                {
                    "name": "staticAnimations",
                    "desc": "",
                    "lua_type": "{ string }?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RideSectionSoundPlugin"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 78,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "extractRangesFromAnimation",
            "desc": "Extracts the ranges for an animation.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<{SectionRange}, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 118,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "getSectionRanges",
            "desc": "Extracts ranges from a map of animations in a RideManager.",
            "params": [
                {
                    "name": "rideManager",
                    "desc": "",
                    "lua_type": "RideManager"
                },
                {
                    "name": "animationList",
                    "desc": "",
                    "lua_type": "{string}"
                },
                {
                    "name": "startTriggerName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "endTriggerName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<AnimationSectionRanges, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 216,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "create",
            "desc": "Create constructor.\n\nCreates a RideSectionSoundPlugin by extracting ranges from Animation using triggers.",
            "params": [
                {
                    "name": "movementSoundPlugin",
                    "desc": "",
                    "lua_type": "RideMovementSoundPlugin"
                },
                {
                    "name": "rideManager",
                    "desc": "",
                    "lua_type": "RideManager"
                },
                {
                    "name": "animationTriggerData",
                    "desc": "",
                    "lua_type": "{[string]: CreateAnimationData}"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<RideSectionSoundPlugin, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 272,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "fromRideManager",
            "desc": "Constructs a RideSectionSoundPlugin by looking through all of the registered animations of the given RideManager\nand extracting ranges with the given triggers.\n\nThis is designed to be a quick and easy constructor.",
            "params": [
                {
                    "name": "movementSoundPlugin",
                    "desc": "",
                    "lua_type": "RideMovementSoundPlugin"
                },
                {
                    "name": "rideManager",
                    "desc": "",
                    "lua_type": "RideManager"
                },
                {
                    "name": "startTriggerName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "endTriggerName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "staticAnimations",
                    "desc": "",
                    "lua_type": "{string}?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<RideSectionSoundPlugin, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 325,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "fromTriggers",
            "desc": "Constructs a RideSectionSoundPlugin by extracting ranges using the following triggers",
            "params": [
                {
                    "name": "movementSoundPlugin",
                    "desc": "",
                    "lua_type": "RideMovementSoundPlugin"
                },
                {
                    "name": "rideManager",
                    "desc": "",
                    "lua_type": "RideManager"
                },
                {
                    "name": "animationList",
                    "desc": "",
                    "lua_type": "{string}"
                },
                {
                    "name": "startTriggerName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "endTriggerName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "staticAnimations",
                    "desc": "",
                    "lua_type": "{ string }?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<RideSectionSoundPlugin, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 358,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "isEnabled",
            "desc": "Returns true if this plugin is currently enabled",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 380,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "setIsEnabled",
            "desc": "Sets whether the plugin is enabled or disabled.\nWhile disabled, the movement sound will not play.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 387,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "_isInSection",
            "desc": "Returns true if animationPlayer",
            "params": [
                {
                    "name": "animationName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "t",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 406,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "isInSection",
            "desc": "Returns true if the animationPlayer is in a section",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 430,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "update",
            "desc": "Updates this plugin",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 440,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "SectionRange",
            "desc": "",
            "fields": [
                {
                    "name": "start",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "stop",
                    "lua_type": "number",
                    "desc": ""
                }
            ],
            "source": {
                "line": 66,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "AnimationSectionRanges",
            "desc": "",
            "lua_type": "{[string]: {SectionRange}}",
            "source": {
                "line": 73,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "CreateRangeInfo",
            "desc": "",
            "fields": [
                {
                    "name": "startTrigger",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "stopTrigger",
                    "lua_type": "string",
                    "desc": ""
                }
            ],
            "source": {
                "line": 252,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        },
        {
            "name": "CreateAnimationData",
            "desc": "",
            "lua_type": "CreateRangeInfo | true",
            "source": {
                "line": 259,
                "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
            }
        }
    ],
    "name": "RideSectionSoundPlugin",
    "desc": "Plays a sound when the ride enters a section of the ride indicated by a range in an animation.\n\nThis is can be used to setup lift anti-rollback sounds for a coaster, sounds that only play when a coaster train is in a certain section of the ride.\n\nStatic Animations are animations where this plugin is *ALWAYS* enabled.\n\n#### Setup\n\n```lua\n-- create MovementSoundPlugin\nlocal movementSoundPlugin = RideMovementSoundPlugin.new(animPlayer, {\n\tfolderName = \"MovementSounds\",\n\tsoundProperties = {\n\t\t-- overwrite properties of Sound\n\t\tSoundId = \"rbxassetid://0000\", -- set sound id here\n\t},\n\n\tuseConstantSpeed = true,\n\tmaxSpeed = 10.0,\n\tminSpeed = 0,\n\n\tmaxVolume = 1.5,\n\tminVolume = 0.0,\n\tmaxPitch = 1.0,\n\tminPitch = 0.5,\n\n\tfadeInTime = 2,\n\tfadeInStyle = Enum.EasingStyle.Quint,\n\tfadeOutTime = 2,\n\tfadeOutStyle = Enum.EasingStyle.Quint,\n})\n\n-- create section sound plugin\nlocal sectionSoundPlugin = RideSectionSoundPlugin.create(\n\tmovementSoundPlugin,\n\trideManager,\n\t{\n\t\t[\"RideAnimation\"] = {\n\t\t\t{\n\t\t\t\tstartTrigger = \"Lift_SECTION_START\",\n\t\t\t\tendTrigger = \"Lift_SECTION_END\",\n\t\t\t}\n\t\t}\n\t}\n):unwrap()\n```",
    "source": {
        "line": 57,
        "path": "src/shared/plugins/rideMovementSound/RideSectionSoundPlugin.lua"
    }
}