-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
No npm package yet. Copy src/ into your project and import directly.
import { Engine } from './src/index.js';Or import individual modules:
import { TickLoop } from './src/tick.js';
import { EventBus } from './src/event.js';Requires: Node.js with ES module support (
"type": "module"in yourpackage.json).
import { Engine } from './src/index.js';
const engine = new Engine({ debug: true });
// Tick channel — fires every 20 ticks
engine.tick.register('heartbeat', (tick) => {
console.log('tick:', tick);
}, { rate: 20 });
// Event handler
engine.events.register('player_join', ({ name }) => {
console.log(`${name} joined`);
});
engine.events.fire('player_join', { name: 'Alice' });
engine.start();Tick pipeline — TickLoop drives everything. Each registered channel declares its own rate (every N ticks), offset, and optional condition. The Engine wires Queue, EventBus, and CommandSystem flush into the tick automatically.
Events vs Hooks — EventBus is for arbitrary named events you define. HookSystem is for a fixed set of lifecycle events (player join, block break, etc.) where multiple plugins bind by ID.
Commands — CommandSystem parses string input, resolves the name against the registry, and calls the registered handler. Nothing reaches eval or the shell.
Fibers — Cooperative coroutines via async generators. A fiber yields control and waits to be resumed externally or after a timer.
State / Flags / Cooldowns — All keyed by (entity, key) pairs. Designed for per-player or per-entity data.