Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld e339ab22-c…

Bus

The one table the game's parts talk over. **Every slice announces what happened and listens for what it cares about; no slice requires another**, and this is the table in the middle they share.

by◐aiden·posted 1d ago
What it does

game.Bus

The one table the game's parts talk over. Every slice announces what happened and listens for what it cares about; no slice requires another, and this is the table in the middle they share.

local Bus = require("game.Bus")

Bus.emit(Bus.E.noise, { id = "sprint", position = p, source = "player" })

local handle = Bus.on(Bus.E.playerCaught, function(payload)
	print(payload.monster) -- "resident"
end)
Bus.off(Bus.E.playerCaught, handle)

Bus.E is the event-name list, spelled once so no slice can invent a string nobody else listens for. It is the same set as GameRules.EVENTS, which also documents the payload each event carries; the scene entrypoint checks the two agree on every load and warns if they have drifted.

on, once, off, emit, count, clear, plus error() and clearError() for the last handler failure.

Two rules, because getting them wrong desynchronises a co-op run

  1. The bus is local. It is a module, and a module is one instance per peer. An emit reaches the parts of the game running on this machine and nowhere else. Anything another player must agree about — a door, a key, the objective list, the monster — is written to the shared store (runtime_data.world, under the keys in GameRules.DATA) and read back by every peer. Emit the local response to a thing; store the fact of it. A part that emits doorOpened and never writes the store has a door that opens for one player and stays shut for everyone else.
  2. An emit is synchronous. Handlers run before emit returns, in subscription order, on the frame the thing happened. The payload table is handed out, not copied — read it, do not keep it, do not mutate it. A handler that throws is caught and reported, so one broken listener cannot silence every other listener on the same event; Bus.error() reads the last one back.

Who calls it: every slice. The house emits doors and pickups, the monsters emit their state and a sighting, the survival systems emit noise, damage and clues, the interface listens to most of it, and the audio director listens to nearly all of it.

Interface

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

conforms to

zero/source-extract/v2

strict

count(event: string) → number

How many listeners an event has. For a slice asking "is anybody listening", and for the tests.

argtypedescription
eventstring

on(event: string, fn: Handler) → number

Listen. Returns a handle; pass it to `off` to stop.

argtypedescription
eventstring
fnHandler

once(event: string, fn: Handler) → number

Listen once: the handler comes off before it runs, so re-entrant emits cannot call it twice.

argtypedescription
eventstring
fnHandler

off(event: string, handle: number) → boolean

argtypedescription
eventstring
handlenumber

emit(event: string, payload: any) → void

Announce. Handlers run now, in subscription order. One throwing does not stop the rest; the failure is reported and remembered in `lastError`.

argtypedescription
eventstring
payloadany

error( ) → string

The last handler failure, and clearing it. A slice can surface this in a debug overlay rather than leaving a broken listener silent.

clearError( ) → void

clear(event: string?) → void

Drop every listener. For a mode change or a restart: a handler left over from a finished run is a handler running against a world that is gone.

argtypedescription
eventstring?

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
This part has no composite children. See the Files segment for its leaf payloads.
backing path · game/Bus.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.