game.module
This package holds more than this page lists. See all of its files in its world.
README.md
game
The game assembled: the WORLD every player shares (clock, districts' colour and
vigilance, murals and the crews that scrub them, paint in the air, cover, marks) and one SESSION per player
(logic.session: her paint, colour, money, crew, vehicles, heat and record, missions, activities, chronicle).
It owns no entity and reads no device. Each tick the host (logic.driver, or a test) hands it one frame per
player; it returns one view per player and emits every moment on its hub. The same code runs one player or
several: heat, saves and progress are each player's own; walls are everyone's.
local Game = require("metropolisGame.logic.game")
local game = Game.new({
city = city, -- interfaces: city (districtAt, walls, place, roadGraph ...)
query = physicsQuery, -- interfaces: physics (raycast, overlap) for paint in the air
hasLine = function(observer, suspect) return true end, -- line of sight for observers
light = nil, -- function(x, z) -> 0..1; default follows the game clock
clock = nil, -- interfaces: clock, when it offers `shared` and `anchor` (several players: the
-- game clock then follows the synced anchor instead of ticking)
seed = 20261122,
})
local session = game:session("p1") -- makes it on first use (a new game for that player)
local views = game:frame(dt, { p1 = {
actor = "actor:p1", -- the id her body has in physics hits (so solvent finds her)
pose = { x, y, z, fx, fz, speed, vx, vz, onGround },
roadClass = "street", -- the class of road she is on (nil off the road)
hidden = false, concealment = {}, jacket = "ochre", stand = 0, mounted = false,
aim = { origin = { x, y, z }, dir = { x, y, z }, site = "old_quay:piece:1", u, v, distance, target = id },
input = { paint, fire, sign, breakHeld, skip },
observers = { [id] = { kind, x, y, z, fx, fz, relay, atRelay, knows, active } },
van = { x, z }, -- where her van stands (for the bill), or nil
route = function(unit, x, z) ... end, -- the host's router for response units (optional)
facts = {}, audience = nil,
} })
views.p1 -- everything her HUD and map draw: data and ids, no text
game:view("p1") -- the same again
game.hub -- every event of every session (e.player says whose) and the world's
game:save() -> { v, world = {...}, players = { [id] = {...} } } game:load(data) -> ok, why
game:saveWorld() game:savePlayer(id) -- the two halves on their own (logic.save writes them)
World parts, all public: clock, districts (districtState), sites, places, murals, gunplay, party, graph.
World hub events: "hour", "dayPassed", "colour", "threshold", "vigilance", "districtPainted", the murals'
("scrubComing" ...), the gunplay's ("shotsFired", "paintedOut", "washed" ...), "relayJammed" { id }, "lensOut" { id }.
The interface is documented in the header of init.luau; this file repeats it for the asset browser.