← Back to Docs
  • index.html
  • Clayground
  • Clayground.Lab
  • Lab
  • Clayground 2026.7
  • Lab QML Type

    Global registry connecting parameters, probes and the sim clock. More...

    Import Statement: import Clayground.Lab

    Properties

    Signals

    Methods

    Detailed Description

    Every Parameter and Probe registers itself here on creation. UI components (ParamPanel, Plot2D) and agents (via eval on the inspector protocol) address them by name through this singleton.

    Example usage:

    import Clayground.Lab
    
    // read a parameter value
    property real g: Lab.p("gravity")
    
    // set one (also the agent-facing entry point)
    Component.onCompleted: Lab.set("gravity", 3.7)

    See also Parameter, Probe, and SimClock.

    Property Documentation

    clock : QtObject

    The active SimClock (set automatically by SimClock).


    flowIds : var [read-only]

    Ids of all registered flows (registration order).


    headless : bool

    No one is watching: skip audio and character travel.

    Set by runFlow() for the length of a headless run and restored afterwards; a host may also set it by hand. What honours it is deliberately small and listed here rather than guessed at: Narrator hides, the professor kit's FlowGuide leaves the character where it is, and pre-rendered narration is not loaded. Nothing about the SIMULATION changes - a flow must traverse the same states headless as it does on screen, or running it as a check proves nothing.


    paramNames : var [read-only]

    Names of all registered parameters (registration order).


    probeNames : var [read-only]

    Names of all registered probes (registration order).


    scenario : string

    Name of the currently applied scenario ("" if none).


    Signal Documentation

    sampled(real t)

    Emitted after all probes took a sample at sim time t.

    Note: The corresponding handler is onSampled.


    Method Documentation

    void applyViewState(var s)

    Restores parameters and, for world-less clocks, re-steps sim time.

    Sets every parameter in s.params through the clamped set(), then - only when a SimClock exists, is world-less and s.time > 0 - deterministically re-steps it to s.time in fixed 1/60 s increments.

    Ordering contract: the Sandbox root MUST apply s.scenario BEFORE calling this. The scenario apply resets the clock + RNG, so the re-step here replays the exact causal chain (takeSamples -> sampled -> sensors/filter), restoring bit-identical sim state. World-driven (Box2D) clocks cannot be synchronously re-stepped and are left untouched.

    See also viewState.


    void clearProbes()

    Drops all probe samples (done automatically on SimClock.reset).


    var labInfo()

    Standard lab state block for the flagInfo()/labInfo() convention.


    real p(string name)

    Shorthand for the value of the named parameter.


    Parameter parameter(string name)

    Returns the Parameter with the given name (null if unknown).


    Probe probe(string name)

    Returns the Probe with the given name (null if unknown).


    var probeSummary()

    Per-probe {first, last, min, max, count} map.


    var runFlow(string flowId, var opts)

    Runs a registered Flow to its end with nobody watching.

    The headless half of "every flow is also a test": it starts the flow through the lab's own startFlow() when the lab has one, forces pacing: "auto", advances clock in fixed 1/60 s steps and performs every task itself with Flow::solve(). Nothing is waited for in wall-clock time, so a whole lesson runs in well under a second.

    Returns what broke rather than throwing:

    opts.maxSteps (default 20000, i.e. ~5.5 sim minutes) bounds the run so a watch that never comes true is a false finished rather than a hang. opts.solveGrace (default 5 sim seconds) is how long a task gets after being solved before it counts as failed.

    headless is true for the length of the run and restored afterwards.

    See also Flow and headless.


    bool set(string name, real value)

    Sets a parameter value, clamped to its range.


    var viewState()

    JSON-serializable lab state for the live-loader reload convention.

    Returns { scenario, time, params }: the current scenario name (key omitted while empty), the sim-clock time and every registered parameter value. Sandbox roots merge their own camera/toggle state on top and hand the result to the dojo, which re-applies it after the next reload.

    See also applyViewState.