Skip to content

Load Program API Reference

Compiler [Deprecated]

Warning

This API is Deprecated and thus should NOT be used.

API.Compiler

The original keyframe recorder. It operates more like a state machine, and, while simple, it's very bloated. It should not be used with new projects, but it's kept in for legacy code.

Recorder (Module)

API.Recorder

See Recorder API

CFrameTrain

API.CFrameTrain {
    Length: number,
    BaseCFrame: CFrame,

    Cars: CFrameTrainCars[]
    Connectors: CFrameTrainConnector[]
    WheelSetOffsets: number[]
    WheelSetOffsetsBackwards: number[]
}

A version of the train used for CFrame calculations and physics.

CFrameCalculationType

CFrameTrain.CFrameCalculationType {
    OffsetFromWheelSetA: 0,
    OffsetFromFrontCar: 1,
    OffsetFromRearCar: 2,
    OffsetBetweenWheelSets: 3,
}

Enum.

OffsetFromWheelSetA

Moves the car's chassis based on the offset from this car's WheelSetA.

OffsetFromFrontCar

Moves the car's chassis based between this car's WheelSetA and the front car's front most wheelset. If WheelSetB exists, then it is WheelSetB, otherwise it is WheelSetA.

OffsetFromRearCar

Moves the car's chassis based between this car's WheelSetA and the rear car's WheelSetA

OffsetBetweenWheelSets

Set to this if your car's chassis has both a WheelSetA and a WheelSetB.

new

CFrameTrain.new() -> CFrameTrain

Constructor. Creates a new CFrameTrain

FromData

CFrameTrain.FromData(data: table) -> CFrameTrain

Constructor. Creates a new CFrameTrain using a table.

FromInstanceData

CFrameTrain.FromInstanceData() -> CFrameTrain

Constructor. Creates a new CFrameTrain using data defined in Roblox Instances.

InstanceData Children Tree:

// Anything that is an Instance is usually a Folder or Model.
// Anything that is a Model must have it's PrimaryPart set.
// Anything prefixed with "?" is optional.
// CFrameInstance is anything that can be converted into a CFrame.
//  - BasePart
//  - CFrameValue
//  - Vector3Value
//  - ObjectValue->CFrameInstance

instanceData: Instance
    +--> Cars: Instance
    |       +--> 1: Instance
    |       |       +--> CFrameCalculationType: IntValue
    |       |       +--> FrontConnector: CFrameInstance
    |       |       +--> RearConnector: CFrameInstance
    |       |       +--> Chassis: Model
    |       |       +--> ?WheelSetA: Model
    |       |       +--> ?WheelSetB: Model
    |       ...
    |       +--> N: Instance
    |               + ...
    +--> Connectors: Instance
    |       +--> 1: Model
    |       |       +--> FrontCar: IntValue
    |       |       +--> RearCar: IntValue
    |       ...
    |       +--> N: Instance
    |               + ...
    +--> Seats: Instance
            +--> 1: Instance/ObjectValue
            |       +--> 1: Instance/ObjectValue
            |       |       +--> 1: Seat/ObjectValue
            |       |       +--> N: ...
            |       +--> N: ...
            +--> N: ...

CFrameTrack

API.CFrameTrack {
    Name: string,
    Length: number
}

Determines where a train moves. Also used in physics calculations.

CreateCFrameTrack

API.CreateCFrameTrack(instance: Instance, ?name: string = instance.Name) -> CFrameTrack

Helper function to create a new CFrameTrack from Instance data.

Uses a child called TrackClass, a StringValue, to determine the class to use.

TrackClass:

  • PointToPoint
  • PointToPoint2
  • Turntable
  • MovingSection
  • TweenedPoints

InstanceData Children Tree:

instance: Instance
    +--> TrackClass: StringValue
    ...

PointToPoint

instance: Instance
    +--> TrackClass: StringValue
    |       +-- Value: "PointToPoint"
    +--> IsCircuited: BoolValue
    +--> DistanceBetweenPoints: NumberValue
    +--> Points: Instance
            |--> 1: CFrameInstance
            |--> 2: CFrameInstance
            |--> ...
            |--> N: CFrameInstance

PointToPoint2

instance: Instance
    +--> TrackClass: StringValue
    |       +-- Value: "PointToPoint2"
    +--> IsCircuited: BoolValue
    +--> HashValue: NumberValue
    +--> Points: Instance
            |--> 1: CFrameInstance
            |--> 2: CFrameInstance
            |--> ...
            |--> N: CFrameInstance

Turntable

instance: Instance
    +--> TrackClass: StringValue
    |       +-- Value: "Turntable"
    +--> Axis: StringValue
    +--> CenterPoint: CFrameInstance
    +--> Offset: CFrameInstance
    +--> ?CALC_OFFSET_FROM_CENTER_POINT: Instance
    +--> ?CALC_OFFSET_FROM_OBJECT: Instance

MovingSection

instance: Instance
    +--> TrackClass: StringValue
    |       +-- Value: "MovingSection"
    +--> IsCircuited: BoolValue
    +--> HashValue: NumberValue
    +--> Points: Instance
            |--> 1: CFrameInstance
            |--> 2: CFrameInstance
            |--> ...
            |--> N: CFrameInstance

TweenedPoints

instance: Instance
    +--> TrackClass: StringValue
    |       +-- Value: "MovingSection"
    +--> IsCircuited: BoolValue
    +--> HashValue: NumberValue
    +--> Points: Instance
            |--> 1: CFrameInstance
            |       +--> ?Length: NumberValue
            |--> 2: CFrameInstance
            |       +--> ?Length: NumberValue
            |--> ...
            |--> N: CFrameInstance

TrackSectionsData (Module)

API.TrackSectionsData {
    TrackSectionsData: TrackSectionsData,
    TrackSectionsDataBuilder: TrackSectionsDataBuilder,

    TRACK_TYPE: TrackType.TRACK_TYPE,
}

TrackSectionsData

TrackSectionsData.TrackSectionsData {
    DefaultTrackType: TrackType,
    TypeSections: TypeSection[],
}

Defines the track type for any track. Contains a list of TypeSections. The DefaultTrackType is used if none are found for tyhe given position.

new

TrackSectionsData.new(data: table) -> TrackSectionsData

Constructor. Creates a new TrackSectionsData from a table. Useful for defining your TrackSectionsData in a ModuleScript.

Example:

-- in a ModuleScript
return {
    DefaultTrackType = {
        Type = 0,
        Speed = 0,
        Acceleration = 0,
        Deceleration = 0,
        UsePhysics = true,
        ClampToTrackSpeed = false,
    },
    TypeSections = {    -- must be an array
        [1] = {
            Start = 0,
            End = 1000,

            Type = 3,
            Speed = 10,
            Acceleration = 0.5,
            Deceleration = 0.5,
            UsePhysics = true,
            ClampToTrackSpeed = false,
        },
        -- continued...
    }
}

-- in the recorder script
local data = require(script.MainTrackSectionsData)  -- the path to the module
local trackSectionsData = TrackSectionsData.new(data)

FromInstanceData

TrackSectionsData.FromInstanceData(instanceData: Instance) -> TrackSectionsData

Constructor. Creates a new TrackSectionsData using data defined in Roblox Instances.

InstanceData Children Tree:

// anything that is an Instance are usually Folders or Models

instanceData: Instance
    +--> DefaultTrackType: Instance
    |       +--> Type: IntValue
    |       +--> Speed: NumberValue
    |       +--> Acceleration: NumberValue
    |       +--> Deceleration: NumberValue
    |       +--> UsePhysics: BoolValue
    |       +--> ClampToTargetSpeed: BoolValue
    +--> TypeSections: Instance
            +--> [ANY NAME]: Instance
            |       +--> Start: NumberValue
            |       +--> End: NumberValue
            |       +--> Type: IntValue
            |       +--> Speed: NumberValue
            |       +--> Acceleration: NumberValue
            |       +--> Deceleration: NumberValue
            |       +--> UsePhysics: BoolValue
            |       +--> ClampToTargetSpeed: BoolValue
            ...
            +--> [ANY NAME]: Instance
                    + ...

BuildSection

TrackSectionsData:BuildSection(data: table) -> TypeSectionBuilder

TypeSection

API.TypeSection {
    Start: number,
    End: number,
    TrackType: TrackType
}

Defines a section for a TrackType.

TrackType

API.TrackType {
    Type = TRACK_TYPE,
    Acceleration: number,
    Deceleration: number,
    Speed: number,
    UsePhysics: boolean,
    ClampToTargetSpeed: boolean,
}

Defines the physics type for a track.

TrackType.TRACK_TYPE

TrackType.TRACK_TYPE {
    NONE: 0,
    ACCELERATE: 1,
    DECELERATE: 2,
    TRANSPORT: 3,
    CONSTANT: 4,
}

NONE

  • Will not speed up nor slow down the speed of the train
  • Speed value is not used

ACCELERATE

  • Speeds up the train if it's speed is less than the target Speed amount

DECELERATE

  • Slows down the train if it's speed is greater than the target Speed amount

TRANSPORT

  • Will accelerate or decelerate the train's speed depending on whether it is less than or greater than the target speed

CONSTANT

  • Keeps train's speed at the target speed amount

TrackSectionsDataBuilder

TrackSectionsData.TrackSectionsDataBuilder {

}

Build

TrackSectionsDataBuilder:Build() -> TrackSectionsData

Finish

TrackSectionsDataBuilder:Finish() -> TrackSectionsData

WithDefaultTrackType

TrackSectionsDataBuilder:WithDefaultTrackType() -> TrackTypeBuilder

WithSection

TrackSectionsDataBuilder:WithSection() -> TypeSectionBuilder

TypeSectionBuilder

TrackSectionsData.TypeSectionBuilder {

}

Build

TypeSectionBuilder:Build() -> TypeSection

Finish

TypeSectionBuilder:Finish() -> TypeSection

WithStart

TypeSectionBuilder:WithStart(startPosition: number) -> self

WithEnd

TypeSectionBuilder:WithEnd(endPosition: number) -> self

TrackTypeBuilder

TrackSectionsData.TrackTypeBuilder {

}

Build

TrackTypeBuilder:Build() -> TrackType

Finish

TrackTypeBuilder:Finish() -> TrackType

WithType

TrackTypeBuilder:WithType(trackType: TRACK_TYPE) -> self

WithSpeed

TrackTypeBuilder:WithSpeed(speed: number) -> self

WithAcceleration

TrackTypeBuilder:WithAcceleration(acceleration: number) -> self

WithDeceleration

TrackTypeBuilder:WithDeceleration(deceleration: number) -> self

WithUsePhysics

TrackTypeBuilder:WithUsePhysics(value: boolean) -> self

WithClampToTargetSpeed

TrackTypeBuilder:WithClampToTargetSpeed(value: boolean) -> self