Skip to content

Debug view ​

Debugging only

VideState.debug exists to inspect handlers while you develop. Do not use it to drive game logic.

The debug tools show what your handlers are doing: their state, whether a transition is running or paused, and how many onTransition connections they have. Tracking is opt-in, so a handler only shows up after you pass it to track.

luau
const Vide = require("@packages/Vide")
const VideState = require("@VideState")

const schemas = VideState.schemas
const rules = VideState.rules

const PanelRule = rules.dynamic(schemas.new({
    visible = schemas.boolean(),
}), { name = "Panel" })

-- `panel` is a handler made from the rule, one for each panel on screen.
const panel = PanelRule.new({
    Idle = { visible = Vide.source(false) },
    Active = { visible = Vide.source(true) },
}, "Idle")

-- List it in the debug view as "Main panel". Call `untrack()` to remove it again.
const untrack = VideState.debug.track(panel, "Main panel")

view shows the tracked handlers in a list that refreshes while it exists. Mount it in a UI Labs story, or in a debug screen in your game. The repository has a story in stories/DebugView.story.luau that you can copy.

Functions ​

track Added in 0.2.0 ​

luau
VideState.debug.track(
    handler: Handler<T>, -- The handler to list
    label: string? -- The name to list it under
) -> Disconnect

Lists a handler in list and the view, under label or the name of its rule. Tracking a handler again changes its label. A tracked handler stays listed until you call the returned function, or until it is destroyed.

Parameters

NameTypeDescription
handlerHandler<T>A handler created by a rule.
labelstring?Optional. The name to list it under. Defaults to the rule name.

Returns

TypeDescription
DisconnectCall it to stop listing the handler.

Errors

CauseMessage
Errorhandler is not a handlerdebug.track expects a handler
Errorlabel is not a stringdebug.track label must be a string

snapshot Added in 0.2.0 ​

luau
VideState.debug.snapshot(
    handler: Handler<T> -- The handler to read
) -> DebugSnapshot

Reads what a handler looks like right now, whether or not it is tracked.

Parameters

NameTypeDescription
handlerHandler<T>A handler created by a rule.

Returns

TypeDescription
DebugSnapshotThe handler's state at this moment.

Errors

CauseMessage
Errorhandler is not a handlerdebug.snapshot expects a handler

list Added in 0.2.0 ​

luau
VideState.debug.list() -> { DebugSnapshot }

Reads every tracked handler, in the order they were first tracked. Destroyed handlers are left out and stop being tracked.

Returns

TypeDescription
{ DebugSnapshot }One snapshot per tracked handler.

view Added in 0.2.0 ​

luau
VideState.debug.view() -> Frame

Creates a Vide component that lists the tracked handlers, one line each, such as Main panel Active running 0.42 s 2 connections. It refreshes ten times a second while it exists. Call it inside a Vide scope, such as Vide.mount, Vide.root, or a UI Labs story, so its refresh stops when the scope is destroyed.

Returns

TypeDescription
FrameThe list, sized to fill its parent.

setFallbackWarnings Added in 0.6.0 ​

luau
VideState.debug.setFallbackWarnings(enabled: boolean)

Turns a warning on or off for a tween setting source that returns an invalid value. A transition keeps running when that happens, with "linear" for easing, 0.25 for duration, 0 for delay, and normal speed (or 0 for a negative one) for speed, so a typo can go unnoticed. With the warning on, each stretch of invalid values warns once per source, not every frame. It is off by default.

CauseMessage
Errorenabled is not a booleandebug.setFallbackWarnings expects a boolean, got <type>

isFallbackWarnings Added in 0.6.0 ​

luau
VideState.debug.isFallbackWarnings(): boolean

Returns whether the fallback warnings are on.

Types ​

DebugSnapshot Added in 0.2.0 ​

luau
type DebugSnapshot = {
    label: string, -- The label passed to track, or the rule name
    rule: string, -- The name of the rule that created the handler
    state: string, -- The active state
    connections: number, -- How many onTransition connections the handler has
    isRunning: boolean, -- Whether a transition is running
    isPaused: boolean, -- Whether the handler is paused
    isDestroyed: boolean, -- Whether the handler was destroyed
    startedAt: number?, -- When the most recent transition started
}
FieldTypeDescription
labelstringThe label passed to track, or the rule name.
rulestringThe name of the rule that created the handler.
statestringThe active state.
connectionsnumberHow many onTransition connections the handler has.
isRunningbooleanWhether a transition is running.
isPausedbooleanWhether the handler is paused.
isDestroyedbooleanWhether the handler was destroyed.
startedAtnumber?The os.clock() time at which the most recent transition started, or nil before the first one.