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
Evaluate: ((localTime: number) → {[string]: any})?--
Sampled: returns property values for localTime
Enter: ((offset: number) → ())?--
Triggered: the section starts, offset seconds in
Update: ((localTime: number) → ())?--
Triggered: called each frame while active
Seek: ((localTime: number) → ())?--
Triggered: the playhead jumped within the section
}SectionContext
interface SectionContext {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,property: string,value: any) → boolean--
Writes a property so it can be restored
IsPlaying: (self) → boolean--
False while paused or scrubbing
GetDuration: (self) → numberGetTimeScale: (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: SequenceDataTrack: TrackDataSection: SectionData}Properties
VALUE_TYPES
This item is read only and cannot be modified. Read OnlySectionTypes.VALUE_TYPES: {[string]: true}Value types a parameter declaration may use. Enum types are declared as "Enum.<EnumType>" instead.
Changed
SectionTypes.Changed: SignalFires when a section type is registered or unregistered.
Functions
IsEnumType
SectionTypes.IsEnumType(typeName: string) → booleanWhether typeName is an "Enum.<EnumType>" declaration.
GetEnumType
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
GetAll
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) → booleanGetSource
The ModuleScript a custom section type was loaded from.
LoadFolder
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
Types
interface ParameterDeclaration {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.