Log inGet started
World

Painted Metropolis

Branchmain
Commit1e1d3a3d4d

README.md

cover

How painted a thing is, and the moment it is painted out.

Cover is the health of everything paint can stop: a guard's visor and body, a windscreen, a lens, a relay.
Nothing dies. A thing has parts (cfg.cover.kinds[kind].parts); each hit adds cover to one part; a part fires
its effects as its cover rises through their thresholds (a visor at 0.3 blinds for four seconds); when the
kind's `out` rule is met the thing is PAINTED OUT: it stops doing what it does for `out.seconds`, or until it
is repaired when the rule gives no seconds. Parts that are left alone wipe themselves clean again.

  local Cover = require("~.modules.cover")
  local cover = Cover.new(cfg.cover)
  cover:add("w3", "guard")                       -- register a thing of a kind (false for an unknown kind)
  local events = cover:hit("w3", "visor", 0.34)  -- cover added to a part (nil part: the kind's defaultPart)
  -- { type = "cover", id, kind, part, value, delta }
  -- { type = "effect", id, kind, part, effect, seconds, offence }    a threshold crossed
  -- { type = "out", id, kind, effect, seconds, offence }             painted out
  local later = cover:tick(dt)                   -- { type = "back", id, kind } when it returns; wiping happens here
  cover:isOut("w3")   cover:outLeft("w3")        -- seconds left (math.huge when it waits for repair, 0 when in)
  cover:value("w3", "visor")   cover:total("w3") -- 0..1 of a part, and the mean over its parts
  cover:repair("w3")                             -- cleaned by hand: back at once, every part empty
  cover:remove("w3")
  cover:view("w3")     -- { id, kind, out, outLeft, total, parts = { { part, value } } } for a meter over a target
  cover:serialise()    Cover.restore(cfg.cover, rows)     -- only kinds marked persist = true

A thing that is out takes no more cover until it is back.

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