Skip to content

Defining Instructions

march edited this page Dec 28, 2024 · 1 revision

Instructions can be defined on a per-addon basis. All you need to do is create a new file in lua/ponder/instructions_cl/ and call a few API methods. As with storyboards, if Ponder is not installed on the server, these files will never get loaded.

ℹ You should create a unique file-name for your instruction. Typically, Ponder-made instructions use this format: ponder.(name-in-lowercase).lua.

ℹ You can also place instruction definitions in folders, as long as the root folder is lua/ponder/instructions_cl/.


To get started, in your new file, start with a call to Ponder.API.NewInstruction, like so:

local YourNewInstruction = Ponder.API.NewInstruction("YourNewInstruction")

ℹ Make sure to pick a unique name for your instruction here as well; to prevent overriding other addons. Something like Addon.InstructionName is what I'd personally recommend.``.


All instructions have these three properties:

Time

The time-offset (additive to the chapter's own Time offset) for the instruction. Default 0.

Length

The length of the instruction. Some instructions do nothing with this; regardless, this property will affect the parent chapter's length (see Chapter for more information on how chapter timing in Ponder works). Default 0.

AddToTimeOffset

A niche (only used in one place, really) parameter that adjusts the parent chapter's time offset. When an instruction with this parameter set to true is added to a chapters instructions, the chapter adds the instructions length to the chapters time offset. Delay is the only built-in instruction that uses this, and it is used for easy time offsets (rather than, for example, having to define Time on every single instruction). Default false.


Instructions can implement the following methods:

Instruction:First(Playback playback)

Runs once Playback has detected this instruction needs to be ran (Instruction.Time >= Playback.Time).

ℹ Only runs once.

Instruction:Last(Playback playback)

Runs once Playback has detected this instruction is done ((Instruction.Time + Instruction.Length) >= Playback.Time).

ℹ Only runs once.

Instruction:Update(Playback playback)

Runs while Playback is keeping track of this instruction (Playback.Time in range Instruction.Time -> Instruction.Time + Instruction.Length).

ℹ Will run one more time before Last() is called to ensure a 1 value is possible in 0-1 progress methods.

Instruction:Render3D(Playback playback)

Runs during the Environment's 3D rendering stage.

Instruction:Render2D(Playback playback)

Runs during the Environment's 2D rendering stage.

Clone this wiki locally