Modules

Plugins

A plugin adds something to a game that happens in the world or in the player's browser: drawing, input, cameras, sound, interface, physics, the ground. A scene turns one on by listing it in its plugins, and gives it its numbers in world.<name>.

A plugin has a server half, a browser half, or both. The server half holds rules and answers questions about the world, and runs wherever the truth runs, and in the page too when the page runs the scene ahead of the server. The browser half runs once for each player's page.

Plugins run in the order the scene lists them. On the page every plugin's tick runs, then every actor's, then every plugin's afterTick, and the renderers draw in their own afterTick. A plugin that places what it draws by the camera is therefore listed before its renderer.

Addons

An addon holds a truth: its seats, connections, sockets, files, timers, more than one truth in a process, and what each packet carries. It runs where the truth is. Addons are the world's machinery, such as the wire between a page and its server (socket, loopback), running a scene ahead of its server (predict), putting a late press back on the step it was made on (rewind), and where durable records are kept (persist).

Four modules are both: scenemanager, player, persist and vision each have a plugin and an addon of the same name. Their page covers both, and the index marks them +addon.

Mods

A mod hands what one plugin knows to another, so that neither reaches into the other. Plugin a supports plugin p with a mod, a file in a's folder named <a>.<p>.ts. A scene switches it on by naming a in world.<p>.mods:

"world": {
  "skydome3d": { "mods": { "land": "terrain3d" } },
  "box3d": { "mods": { "props": ["terrain3d", "solids"] } }
}

The key is the function p asks for, and the value is the plugin that supplies it. A list gives p the same function from several plugins, for a p that takes it from all of them. Swapping one provider for another that exports the same function is changing one value.

A mod is a function of whatever p asks it with: the server's world on the server, or on the page the plugins the page holds. A plugin that supplies a mod to a page must be listed in the scene. Some plugins also need the provider listed before them, because they read what it made earlier in the same frame, and tell you when it is not.

This is why the sea does not take sky: "skydome3d" in its settings. It asks for a light mod, and the scene says which plugin gives it.

The engine

The engine itself is frozen. Everything new is a plugin, an addon, or a game's own kind.

Finding a module

The index groups the pages by what they are for.

  • Rendering & look
    Drawing a scene in 2D or 3D, with sprites, particles, light, sky, sea and effects. render2d, render3d
  • World & ground
    Terrain, trees, tile maps, grids, generated levels and paths through them. terrain3d, tilemap
  • Physics & movement
    Rigid bodies, characters, vehicles, aircraft, shots and bullets. box2d, box3d
  • Cameras
    Following a row, panning, and moving between rooms. chasecamera3d
  • Game flow & UI
    Scenes, cutscenes, the HUD and the page's own settings. scenemanager, ui
  • Sound
    Sound effects, and music written as notes. audio, synthaudio
  • Players & social
    Seats, chat, parties, and bots that play. player, party
  • Networking
    Wires, prediction, rewinding late presses, and sending each seat only what it sees. socket, predict
  • Persistence
    Durable records, accounts, and actors that live in the page only. persist, accounts
  • Infrastructure
    The loader, shipping a game's own plugins, deterministic math, and the recorder and simulator. loader, math