scope
Stores state between frames at named keys. Unused values are cleared next frame.
Constructors: scope.new
Types
Shared type
luau
type Shared = {
frame: number,
dt: number,
time: number,
cleanup_queue: { Scope },
}Scope type
luau
type Scope = setmetatable<{
shared: Shared,
flipped_on: number,
previous: { [string | number]: any },
current: { [string | number]: any },
value: unknown,
pending: unknown,
pending_frame: number?,
parent: Scope?,
cleanups: { unknown },
purged: boolean,
}, typeof(scope)>Functions
new
luau
scope.new(): ScopeReturns a new scope.
Methods
next
luau
scope:next(dt: number)key
luau
scope:key(name: string | number): Scopeon_cleanup
luau
scope:on_cleanup<T>(item: T): Tdestroy
luau
scope:destroy()once
luau
scope:once<T>(init: () -> T): Tset
luau
scope:set<T>(value: T): Tget
luau
scope:get<T>(default: T): Tframe
luau
scope:frame(): numberdt
luau
scope:dt(): numbertime
luau
scope:time(): number