driver.module
This package holds more than this page lists. See all of its files in its world.
README.md
driver
The engine-free half of the host: it runs the game against the thirteen
interfaces (metropolisGame.interfaces). A scene supplies one thin adapter per interface and calls
`driver:tick(dt)`; a test supplies metropolisGame.fake.world. Nothing in here touches the engine.
Each tick it: reads each player's body, vehicle, reticle and controls; turns presses into the session's actions
(take a wheel, change arm, shed a jacket); gathers who can watch (fixed eyes, passers-by dealt into informers
and friends by the district's rule, the response units); runs the game; moves every response unit by the
intent the game gave it (people through `actors.move`, cars through `vehicles.drive`); keeps the number of
Wardens in the world at what the heat asks for, bringing them in out of sight; sends witnesses to their call
boxes; hands the frame's paint to `fx`; and turns hub events into gestures, sounds, camera shots, UI calls and
the host verbs of mission stage directions. It autosaves through `save`.
local Driver = require("metropolisGame.logic.driver")
local driver = Driver.new(host, { seed = 20261122, autosave = 60 }) -- raises with the missing functions
driver.game -- logic.game
driver:addPlayer("p1") -- her session, loaded from her store if there is a save
driver:removePlayer("p1") -- saved and dropped
local views = driver:tick(dt) -- { [playerId] = view }
driver:save() -- write the world and every player now
What the host tells it (from interactKit, dialogueKit, its own triggers):
driver:interacted("p1", id) -- she used something the driver offered through `interact`
driver:event("p1", name, payload) -- something happened that missions listen for (arrived, freight_gone ...)
driver:choose("p1", option) -- she answered the decision a mission or activity is waiting on
driver:facts("p1") -- the facts her missions see now (for a dialogue's conditions)
driver.units -- [unitId] = { id, kind, player, actor, vehicle, crew = { actorId } }
driver.staged -- [stageId] = { kind = "actor" | "vehicle", id } things missions put in the world
Driver.REACTIONS -- hub event -> { sound, gesture, shot, note } (data: retune it freely)
Driver.citizenKind(seed, shares, def, night) -- what a passer-by is to the game (the host may label its crowd with it)
What it expects of the city for response units: places of kind "post" (content.places) to bring Wardens in
from, and `city.route` for their paths.
The interface is documented in the header of init.luau; this file repeats it for the asset browser.