Log inGet started
World

Painted Metropolis

Branchmain
Commit1e1d3a3d4d

README.md

director

The kit assembled: one object a game ticks once a frame.

It runs perception for every registered observer, fills their awareness, opens and lands reports, adds heat,
advances the incident, runs every pursuer's reach and, when one lands, the arrest sequence. It moves nothing
and draws nothing. The game tells it where things are and listens to its hub.

  local Director = require("~.modules.director")
  local dir = Director.new(cfg, {
      hasLine = function(observer, suspect) return true end,   -- is the line between them clear? (required)
      light = function(x, z) return 1 end,                     -- 0 dark .. 1 day at a place (default 1)
      bill = function(level, ctx) return {} end,               -- the arrest's bill (arrest.bill) (optional)
  }, hub?)

  dir:setObserver("w1", { kind = "guard", x, y, z, fx, fz, active = true, relay = "box3"?, atRelay = false?,
                            knows = false? })     -- y: height (default 0); knows: it knows the suspect's face
  dir:removeObserver("w1")
  (cfg.acts must name "wanted": what an observer that is already certain takes the suspect to be doing;
   cfg.heat.offences must name "seen" and cfg.arrest.breakOffence.)
  dir:setSuspect({ x, y, z, act = "idle", concealment = { "crowd" } (pass {} to clear), hidden = false, strikes = 0,
                   appearance = { jacket = "ochre" }, inVehicle = false, speed = 0, charges = 1,
                   fillFactor = 1,      -- a host factor on being noticed (a hot car 1.4, a taxi 0.6)
                   grabFactor = 1 })    -- scales a pursuer's reach (a suspect who cannot run: 2)
  dir:input({ breakHeld = false, skip = false })       -- the suspect's inputs during an arrest
  dir:offence("vandalism")                              -- heat for a named offence, if anyone saw (returns points)
  dir:stun("w1", 4)                                     -- an observer cannot see or reach for that long
  dir:jamRelay("box3")                                  -- cancels the reports that need that relay (returns count)
  dir:report({ x, z, offence = "stolenVehicle"?, delay = 0?, appearance = {}?, quiet = false? })
                                                        -- a report from outside the observers (a car's owner, an
                                                        -- accomplice's incident); quiet: the place only, no heat
  dir:noise({ x, z, radius })                           -- a loud thing happened there: observers in earshot turn
                                                        -- suspicious whatever they can see (returns how many heard)
  local view = dir:tick(dt)
  -- view = incident:view() plus:
  --   watchers = { { id, kind, value, stage } }   highest first
  --   reports = { { id, left, delay, via, relay, held } }
  --   grab = { by, progress } | nil      a reach winding up, or the vehicle box filling (by = "box")
  --   arrest = arrestSeq:view() | nil
  --   described = { tags }               what of the current appearance they know

Parts, all public: dir.heat, dir.incident, dir.awareness, dir.reports, dir.description, dir.arrest, dir.hub.
Hub events beyond those of heat and incident: "observer" { type = suspicious | alert | calm, id, kind },
"cheer" { id }, "reportOpened" { id, delay, via, relay }, "reportLanded" { id, offence, x, z },
"grabWindup" { by }, "grabMissed" { by }, "arrestStage" { stage, sequence, ctx }, "arrestBroke" {}, "arrestDone"
{ bill, level, sequence, outcome }, "heard" { x, z, by = { id, ... } }.

Who grabs decides what follows: an observer kind may name `sequence` (cfg.arrest.sequences[name], its own
stages and `outcome`); kinds that name none run cfg.arrest.stages with outcome "arrest". A sequence may say
`handover = { atLevel }`: when it ends with the heat at that level or above, the main arrest follows at once
(private guards who detain and call the real pursuers).

The interface is documented in the header of init.luau; this file repeats it for the asset browser.