Skip to content

Class ScriptScheduler

Namespace: Apogee.Scripting
Assembly: Apogee.Scripting.dll

The tasks of one VM (and its tweens, which it steps and cancels along with them): what task.spawn, task.defer, task.delay and task.every start, and what task.wait puts to sleep. A task is a Luau thread the scheduler resumes: at once (spawn), at the next drain (defer), when its time comes (delay, wait, every). There is no clock in here: says how much game time and real time passed, so a test drives it with a fake clock and the engine drives it with the frame. Every resume is a protected resume under the time budget of the task's owner, and the thread keeps the memory category of the script that started it. Not thread safe: use it from the thread that made the VM.

public sealed class ScriptScheduler

Inheritance

object ← ScriptScheduler

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

Count

The tasks that have not ended: asleep, deferred or running.

public int Count { get; }

Property Value

int

RealTime

Real seconds since the VM started, whatever the time scale: the clock of task.wait_real.

public double RealTime { get; }

Property Value

double

Time

Game seconds since the VM started: what task.time() gives, and the clock of task.wait, task.delay and task.every. It stops while the game's time scale is 0.

public double Time { get; }

Property Value

double

TweenCount

The tweens that have not ended: playing, delayed or paused.

public int TweenCount { get; }

Property Value

int

Methods

CancelAll()

Stops every task and tween: the VM is going away. A tween stopped this way emits no signal.

public void CancelAll()

CancelOwner(ScriptOwner)

Stops every task and tween of owner: what a mod that failed to load leaves behind. A tween stopped this way emits no signal.

public void CancelOwner(ScriptOwner owner)

Parameters

owner ScriptOwner

CountOf(ScriptOwner)

The tasks of owner that have not ended.

public int CountOf(ScriptOwner owner)

Parameters

owner ScriptOwner

Returns

int

TweenCountOf(ScriptOwner)

The tweens of owner that have not ended.

public int TweenCountOf(ScriptOwner owner)

Parameters

owner ScriptOwner

Returns

int

TaskFailed

Raised when a task ends with an error, a timeout or a memory error (it is logged too), with its owner and the message. The script that started the task never sees the error.

public event Action<ScriptOwner, string>? TaskFailed

Event Type

Action<ScriptOwner, string>?