Skip to content

Home › Overview › ink

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(): Scope

Returns a new scope.

Methods ​

next ​

luau
scope:next(dt: number)

key ​

luau
scope:key(name: string | number): Scope

on_cleanup ​

luau
scope:on_cleanup<T>(item: T): T

destroy ​

luau
scope:destroy()

once ​

luau
scope:once<T>(init: () -> T): T

set ​

luau
scope:set<T>(value: T): T

get ​

luau
scope:get<T>(default: T): T

frame ​

luau
scope:frame(): number

dt ​

luau
scope:dt(): number

time ​

luau
scope:time(): number