Skip to main content

SectionTypes

The registry of section types. Built-in types and custom ones are validated against the same declarative schema, so a custom type is a peer of the built-ins rather than a second-class extension.

A custom section type is a ModuleScript in Flow.CustomSections (or imported through the editor) that returns a [SectionTypes.SectionTypeModule]:

return {
	Name = "Pulse",
	Capability = "Sampled",
	SubjectClass = "BasePart",
	Parameters = {
		Intensity = { Type = "number", Default = 1, Keyframable = true, Min = 0, Max = 1 },
	},
	Evaluate = function(context, localTime)
		local intensity = context:GetParameter("Intensity", localTime)
		return { Transparency = (math.sin(localTime * math.pi * 2) + 1) / 2 * intensity }
	end,
}

A sequence that uses a type the place does not have still plays; its sections of that type do nothing.

Types​

SectionTypeModule​

interface SectionTypeModule {
Name: string--

Identifier-like and unique

Capability: "Sampled" | "Triggered"--

Sampled sections are pure functions of time; triggered ones run side effects

SubjectClass: string?--

The class the subject must be, such as "BasePart"

Description: string?
PlaysSequence: boolean?--

Gets a child runtime for the sequence it targets as context.Child

TrackType: string?--

Restricts the section to one track type; nil runs on any track whose subject fits

Parameters: {[string]: ParameterDeclaration}--

Use {} for none

Evaluate: ((
context: SectionContext,
localTime: number
) → {[string]: any})?--

Sampled: returns property values for localTime

Enter: ((
context: SectionContext,
offset: number
) → ())?--

Triggered: the section starts, offset seconds in

Update: ((
context: SectionContext,
localTime: number
) → ())?--

Triggered: called each frame while active

Exit: ((context: SectionContext) → ())?--

Triggered: the section ends, or playback stops early

Seek: ((
context: SectionContext,
localTime: number
) → ())?--

Triggered: the playhead jumped within the section

}

SectionContext​

interface SectionContext {
Subject: Instance?--

The instance the section's track resolved to

State: {[any]: any}--

Scratch space for the section's hooks, kept for the life of the playback

Child: any?--

The child runtime, for section types that set PlaysSequence

Phase: ("Heartbeat" | "Render")?--

The phase being evaluated, set only on tracks that evaluate in every phase

GetParameter: (
self,
key: string,
localTime: number?
) → any--

A section parameter, sampled at localTime if keyframed

GetSequenceParameter: (
self,
key: string
) → any--

A sequence parameter, including per-play overrides

SetProperty: (
self,
instance: Instance,
property: string,
value: any
) → boolean--

Writes a property so it can be restored

IsPlaying: (self) → boolean--

False while paused or scrubbing

GetDuration: (self) → number
GetTimeScale: (self) → number--

Playback rate times time dilation, for sections that run a clock of their own

GetWeight: (
self,
localTime: number?
) → number--

The section's blend weight, for triggered sections to apply themselves

Sequence: SequenceData
Track: TrackData
Section: SectionData
}

Properties​

VALUE_TYPES​

This item is read only and cannot be modified. Read Only
SectionTypes.VALUE_TYPES: {[string]: true}

Value types a parameter declaration may use. Enum types are declared as "Enum.<EnumType>" instead.

Changed​

SectionTypes.Changed: Signal

Fires when a section type is registered or unregistered.

Functions​

IsEnumType​

SectionTypes.IsEnumType(typeName: string) → boolean

Whether typeName is an "Enum.<EnumType>" declaration.

GetEnumType​

SectionTypes.GetEnumType(typeName: string) → Enum?

Resolves an "Enum.<EnumType>" declaration to its Enum, or nil if no such enum exists.

Validate​

SectionTypes.Validate(candidate: any) → (
boolean,--

Whether it conforms

{string}--

Every problem found, empty when it conforms

)

Checks a candidate module against the section type schema without registering it.

Register​

SectionTypes.Register(
source: Instance?
) → (
boolean,--

Whether it was registered

{string}--

Validation errors when it was not

)

Validates and registers a section type, replacing any with the same name. Pass the source ModuleScript to mark it as custom.

Unregister​

SectionTypes.Unregister(name: string) → ()

Removes a custom section type. Built-in types cannot be unregistered.

Get​

SectionTypes.Get(name: string) → SectionTypeModule?

GetAll​

SectionTypes.GetAll() → {[string]: SectionTypeModule}

Returns the registry itself; do not modify it.

GetNames​

SectionTypes.GetNames() → {string}

Built-in names first, then custom names alphabetically.

IsCustom​

SectionTypes.IsCustom(name: string) → boolean

GetSource​

SectionTypes.GetSource(name: string) → Instance?

The ModuleScript a custom section type was loaded from.

LoadFolder​

SectionTypes.LoadFolder(folder: Instance?) → LoadResult

Types

​

interface LoadResult {
Loaded: {string}--

Names registered

Errors: {[string]: {string}}--

Validation errors, by module name

}

Requires every ModuleScript in folder and registers the ones that conform. Custom types whose module is no longer in the folder are unregistered.

GetDefault​

SectionTypes.GetDefault(declaration: ParameterDeclaration) → any

Types

​

interface ParameterDeclaration {
Type: string--

A key of SectionTypes.VALUE_TYPES, or "Enum.<EnumType>"

Default: any--

Must match Type

Keyframable: boolean?--

Whether the editor offers keyframes for it

Min: number?--

Number parameters only

Max: number?--

Number parameters only

Description: string?
}

Returns the parameter's default value. An Any parameter may default to nil.

Show raw api
{
    "functions": [
        {
            "name": "IsEnumType",
            "desc": "Whether `typeName` is an `\"Enum.<EnumType>\"` declaration.",
            "params": [
                {
                    "name": "typeName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 216,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "GetEnumType",
            "desc": "Resolves an `\"Enum.<EnumType>\"` declaration to its `Enum`, or nil if no such enum exists.",
            "params": [
                {
                    "name": "typeName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Enum?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 224,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "Validate",
            "desc": "Checks a candidate module against the section type schema without registering it.",
            "params": [
                {
                    "name": "candidate",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "Whether it conforms",
                    "lua_type": "boolean"
                },
                {
                    "desc": "Every problem found, empty when it conforms",
                    "lua_type": "{ string }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 234,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "Register",
            "desc": "Validates and registers a section type, replacing any with the same name. Pass the `source` ModuleScript\nto mark it as custom.",
            "params": [
                {
                    "name": "module",
                    "desc": "",
                    "lua_type": "SectionTypeModule"
                },
                {
                    "name": "source",
                    "desc": "",
                    "lua_type": "Instance?"
                }
            ],
            "returns": [
                {
                    "desc": "Whether it was registered",
                    "lua_type": "boolean"
                },
                {
                    "desc": "Validation errors when it was not",
                    "lua_type": "{ string }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 295,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "Unregister",
            "desc": "Removes a custom section type. Built-in types cannot be unregistered.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 313,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "Get",
            "desc": "",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "SectionTypeModule?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 326,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "GetAll",
            "desc": "Returns the registry itself; do not modify it.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ [string]: SectionTypeModule }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 334,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "GetNames",
            "desc": "Built-in names first, then custom names alphabetically.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 342,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "IsCustom",
            "desc": "",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 363,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "GetSource",
            "desc": "The ModuleScript a custom section type was loaded from.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 371,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "LoadFolder",
            "desc": "Requires every ModuleScript in `folder` and registers the ones that conform. Custom types whose module is\nno longer in the folder are unregistered.",
            "params": [
                {
                    "name": "folder",
                    "desc": "",
                    "lua_type": "Instance?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LoadResult\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 380,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "GetDefault",
            "desc": "Returns the parameter's default value. An `Any` parameter may default to nil.",
            "params": [
                {
                    "name": "declaration",
                    "desc": "",
                    "lua_type": "ParameterDeclaration"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 417,
                "path": "runtime/SectionTypes/init.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "VALUE_TYPES",
            "desc": "Value types a parameter declaration may use. Enum types are declared as `\"Enum.<EnumType>\"` instead.",
            "lua_type": "{ [string]: true }",
            "readonly": true,
            "source": {
                "line": 120,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "Changed",
            "desc": "Fires when a section type is registered or unregistered.",
            "lua_type": "Signal",
            "source": {
                "line": 149,
                "path": "runtime/SectionTypes/init.luau"
            }
        }
    ],
    "types": [
        {
            "name": "LoadResult",
            "desc": "",
            "fields": [
                {
                    "name": "Loaded",
                    "lua_type": "{ string }",
                    "desc": "Names registered"
                },
                {
                    "name": "Errors",
                    "lua_type": "{ [string]: { string } }",
                    "desc": "Validation errors, by module name"
                }
            ],
            "source": {
                "line": 28,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "SectionTypeModule",
            "desc": "",
            "fields": [
                {
                    "name": "Name",
                    "lua_type": "string",
                    "desc": "Identifier-like and unique"
                },
                {
                    "name": "Capability",
                    "lua_type": "\"Sampled\" | \"Triggered\"",
                    "desc": "Sampled sections are pure functions of time; triggered ones run side effects"
                },
                {
                    "name": "SubjectClass",
                    "lua_type": "string?",
                    "desc": "The class the subject must be, such as `\"BasePart\"`"
                },
                {
                    "name": "Description",
                    "lua_type": "string?",
                    "desc": ""
                },
                {
                    "name": "PlaysSequence",
                    "lua_type": "boolean?",
                    "desc": "Gets a child runtime for the sequence it targets as `context.Child`"
                },
                {
                    "name": "TrackType",
                    "lua_type": "string?",
                    "desc": "Restricts the section to one track type; nil runs on any track whose subject fits"
                },
                {
                    "name": "Parameters",
                    "lua_type": "{ [string]: ParameterDeclaration }",
                    "desc": "Use `{}` for none"
                },
                {
                    "name": "Evaluate",
                    "lua_type": "((context: SectionContext, localTime: number) -> { [string]: any })?",
                    "desc": "Sampled: returns property values for `localTime`"
                },
                {
                    "name": "Enter",
                    "lua_type": "((context: SectionContext, offset: number) -> ())?",
                    "desc": "Triggered: the section starts, `offset` seconds in"
                },
                {
                    "name": "Update",
                    "lua_type": "((context: SectionContext, localTime: number) -> ())?",
                    "desc": "Triggered: called each frame while active"
                },
                {
                    "name": "Exit",
                    "lua_type": "((context: SectionContext) -> ())?",
                    "desc": "Triggered: the section ends, or playback stops early"
                },
                {
                    "name": "Seek",
                    "lua_type": "((context: SectionContext, localTime: number) -> ())?",
                    "desc": "Triggered: the playhead jumped within the section"
                }
            ],
            "source": {
                "line": 78,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "ParameterDeclaration",
            "desc": "",
            "fields": [
                {
                    "name": "Type",
                    "lua_type": "string",
                    "desc": "A key of [SectionTypes.VALUE_TYPES], or `\"Enum.<EnumType>\"`"
                },
                {
                    "name": "Default",
                    "lua_type": "any",
                    "desc": "Must match `Type`"
                },
                {
                    "name": "Keyframable",
                    "lua_type": "boolean?",
                    "desc": "Whether the editor offers keyframes for it"
                },
                {
                    "name": "Min",
                    "lua_type": "number?",
                    "desc": "Number parameters only"
                },
                {
                    "name": "Max",
                    "lua_type": "number?",
                    "desc": "Number parameters only"
                },
                {
                    "name": "Description",
                    "lua_type": "string?",
                    "desc": ""
                }
            ],
            "source": {
                "line": 89,
                "path": "runtime/SectionTypes/init.luau"
            }
        },
        {
            "name": "SectionContext",
            "desc": "",
            "fields": [
                {
                    "name": "Subject",
                    "lua_type": "Instance?",
                    "desc": "The instance the section's track resolved to"
                },
                {
                    "name": "State",
                    "lua_type": "{ [any]: any }",
                    "desc": "Scratch space for the section's hooks, kept for the life of the playback"
                },
                {
                    "name": "Child",
                    "lua_type": "any?",
                    "desc": "The child runtime, for section types that set `PlaysSequence`"
                },
                {
                    "name": "Phase",
                    "lua_type": "(\"Heartbeat\" | \"Render\")?",
                    "desc": "The phase being evaluated, set only on tracks that evaluate in every phase"
                },
                {
                    "name": "GetParameter",
                    "lua_type": "(self, key: string, localTime: number?) -> any",
                    "desc": "A section parameter, sampled at `localTime` if keyframed"
                },
                {
                    "name": "GetSequenceParameter",
                    "lua_type": "(self, key: string) -> any",
                    "desc": "A sequence parameter, including per-play overrides"
                },
                {
                    "name": "SetProperty",
                    "lua_type": "(self, instance: Instance, property: string, value: any) -> boolean",
                    "desc": "Writes a property so it can be restored"
                },
                {
                    "name": "IsPlaying",
                    "lua_type": "(self) -> boolean",
                    "desc": "False while paused or scrubbing"
                },
                {
                    "name": "GetDuration",
                    "lua_type": "(self) -> number",
                    "desc": ""
                },
                {
                    "name": "GetTimeScale",
                    "lua_type": "(self) -> number",
                    "desc": "Playback rate times time dilation, for sections that run a clock of their own"
                },
                {
                    "name": "GetWeight",
                    "lua_type": "(self, localTime: number?) -> number",
                    "desc": "The section's blend weight, for triggered sections to apply themselves"
                },
                {
                    "name": "Sequence",
                    "lua_type": "SequenceData",
                    "desc": ""
                },
                {
                    "name": "Track",
                    "lua_type": "TrackData",
                    "desc": ""
                },
                {
                    "name": "Section",
                    "lua_type": "SectionData",
                    "desc": ""
                }
            ],
            "source": {
                "line": 108,
                "path": "runtime/SectionTypes/init.luau"
            }
        }
    ],
    "name": "SectionTypes",
    "desc": "The registry of section types. Built-in types and custom ones are validated against the same declarative\nschema, so a custom type is a peer of the built-ins rather than a second-class extension.\n\nA custom section type is a ModuleScript in `Flow.CustomSections` (or imported through the editor) that\nreturns a [SectionTypes.SectionTypeModule]:\n\n```lua\nreturn {\n\tName = \"Pulse\",\n\tCapability = \"Sampled\",\n\tSubjectClass = \"BasePart\",\n\tParameters = {\n\t\tIntensity = { Type = \"number\", Default = 1, Keyframable = true, Min = 0, Max = 1 },\n\t},\n\tEvaluate = function(context, localTime)\n\t\tlocal intensity = context:GetParameter(\"Intensity\", localTime)\n\t\treturn { Transparency = (math.sin(localTime * math.pi * 2) + 1) / 2 * intensity }\n\tend,\n}\n```\n\nA sequence that uses a type the place does not have still plays; its sections of that type do nothing.",
    "source": {
        "line": 61,
        "path": "runtime/SectionTypes/init.luau"
    }
}