Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule zinput.module·originates fromworld 07158574-5…

autoTick

Opt-in per-frame tick loop for zinput. Spawns a `task.spawnSystem` worker that invokes a registered tick function (`Zin.tick`) once per frame, so code-mode snippets and tests without a host script component still drive the stateful subsystems — live binding dispatch, the touch ov…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

autoTick

Opt-in per-frame tick loop for zinput. Spawns a task.spawnSystem worker that invokes a registered tick function (Zin.tick) once per frame, so code-mode snippets and tests without a host script component still drive the stateful subsystems — live binding dispatch, the touch overlay, the emulation floor, axes, chords, rebind, action handlers, event subscribers. task.spawnSystem (not task.spawn) makes the loop system-owned, so it keeps ticking while the editor pauses gameplay.

The first real input read arms this worker on its own. A host script component can also call Zin.tick(dt) from its update(dt) hook, and autoTick.start can be called directly; all three are idempotent alongside each other.

Exports

  • M.start() -> boolean — spawn the worker if not already running. Returns true when a new loop was started.
  • M.stop() — flag the loop to exit on its next yield. No-op if not running.
  • M.isRunning() -> boolean — current status.
  • M._setTickFn(fn: (number?) -> ()) — internal hook. Called once by zinput/init.luau to register Zin.tick.
  • M._setLastTickFrameIdFn(fn: () -> number) — internal hook. Wires the frame-id accessor so the worker can dedup itself against explicit ticks within the same engine frame.

Usage

local Zin = require("@builtin::modules.zinput")

-- One-shot test / code-mode setup:
Zin.autoTick.start()

-- ... later ...
Zin.autoTick.stop()

Notes

  • Single-flight: calling start() twice is a no-op — there is at most one worker per VM.
  • Cross-coroutine dedup: when an explicit Zin.tick ran in the same engine frame, the worker skips that frame so onHeld handlers and event subscribers don't double-fire.
  • Module-local _running survives Luau require-cache reload, so a re-required autoTick.module still reports the loop is live. restart_instance resets the VM and clears everything.
  • start() raises if _setTickFn hasn't been wired yet — always require("@builtin::modules.zinput") first.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

ZinputAutoTick Module Opt-in per-frame tick loop. Spawns a `task.spawnSystem` worker that invokes a registered tick function once per frame. Useful in code-mode / test contexts that lack a host script component. `task.spawnSystem` (not `task.spawn`) so the loop is system-owned and keeps ticking while the editor pauses gameplay, even when `start()` is called from a component's awake() (e.g. the editor free-cam / FreeMover). The first real input read arms this worker on its own, so an input-consuming world ticks with no setup. A host script component can also call `Zin.tick(dt)` from its `update(dt)` hook (matching zui's `app:tick(dt)` pattern), and `Zin.autoTick.start()` can be called directly — running snippets via `execute`, writing tests, prototyping with code-mode. All three are idempotent alongside each other. Single-flight: calling `start()` twice is a no-op. `stop()` flags the loop to exit on its next yield. `isRunning()` reports current status. Hot-reload safety: module-local `_running` survives Luau require- cache reload, so a re-required `autoTick.module` reports the loop is still running. `restart_instance` resets the VM and clears everything.

_setTickFn(fn: (number?) → void

Internal: register the function that the auto-tick loop should call each frame. Wired by `init.luau` at module load.

argtypedescription
fn(number?The tick function (typically `Zin.tick`).

examples

AutoTick._setTickFn(M.tick)

_setLastTickFrameIdFn(fn: () → void

Internal: register the accessor that returns the engine frame id of the most recent `M.tick`. Wired by `init.luau` so the worker can dedup itself against explicit ticks within the same engine frame. Optional — when nil, the worker ticks unconditionally.

argtypedescription
fn(The accessor returning the engine frame id of the last tick.

examples

AutoTick._setLastTickFrameIdFn(M.lastTickFrameId)

isRunning( ) → boolean

True if the auto-tick loop is currently running.

examples

if Zin.autoTick.isRunning() then ... end

start( ) → boolean

Start the auto-tick loop. No-op if already running. already up.

examples

Zin.autoTick.start()

stop( ) → void

Stop the auto-tick loop on its next yield. No-op if not running.

examples

Zin.autoTick.stop()

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

3items
·
other · born here
▤file
▲ 0↑ born
backing path · modules/zinput.module/autoTick.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.