Log inGet started
World

Escapement

Branchmain
Branchesmain
Commit7683e73a7f

README.md

Gearworks

The machine, turning. One of these sits on the entity named Machine, beside the Machine sceneModule that built the metal.

It owns Core.visual.tick and is its only writer. Core.state().tick is the integer the referee resolves against; the visual tick is the same number as a float, sliding from N to N+1 while the advance plays. Everything drawn reads the visual tick — the platforms here, the unit bodies in the units slice, the telegraph in the HUD — so the whole board turns as one motion and every unit is carried by it.

Fields

FieldDeclared defaultWhat it does
advanceSeconds1.2how long the machine takes to turn one tooth
settle1.0how far the train recoils onto the tooth; 0 is a dead stop

A placement keeps the value it was created with, so the one the scene already carries holds advanceSeconds = 1.1 — the declared default above only applies to a placement made after it changed. Read the live value off the component rather than off this table.

The advance

Two stages, both starting and ending at rest. The train is let go, runs past the tooth by about a twelfth of a pitch, hangs there a moment, and is drawn back onto it. That is where the weight comes from — a curve that eases straight to a stop reads as a slide, not a mechanism.

Both stages leave gently on purpose. Anything that chases a platform rather than being parented to it lags behind a hard start, and a hard start is what throws a unit off its own deck.

What one number drives

Every moving part is a pure function of the visual tick, and nothing here runs on wall time:

  • hub_<ring> — the three rings, carrying their wheels, decks and units
  • idler_<gap>_<n> — each compound pinion, at -T_ring / T_pinion times its inner ring, which is what holds its teeth interleaved at every tick and not only at rest
  • bridge_* / gate_* — a plank per crossing the machine currently offers: flat and seated while two teeth are within Core.COUPLE_TOLERANCE, lifting clear as they part, put away past bridgeApproach
  • EscapeWheel — one tooth per tick
  • PalletFork — rocking from pallet to pallet as it goes
  • weight_<n> — the counterweights paying out, bouncing as the train drops them
  • farwheel_<n>, GreatWheel — the rest of the movement, under the same escapement as everything else: running hard through an advance, poised between

Being a pure function of the tick is what keeps an idle board still. A part turning on its own clock would leave the scene permanently drifting from what it was saved as.

Holding entities across a rebuild

The sceneModule beside it despawns and respawns what it builds every time it is edited, and a proxy held across that goes dead. So the driver caches one id per family of parts and probes them each frame; the moment one stops existing it re-resolves everything. public:cache() does the resolving and reports what it found, which is also the quickest way to check the machine is fully wired.