Painted Metropolis
README.md
paintKit
Paint as a game system: what you carry, what the tools do, what a mural is meant to be and how well it was done; and paint as a weapon: arms that fire pigment as real projectiles, cover as the health of everything paintable, "painted out" instead of dead, the painter's own colour stripped by solvent, and marks that stay on walls, cars and people. Engine-free logic configured by data; nothing in it names a game.
Status (2026-11-22): logic run in the engine through caseBench (62 cases pass). engineAdapters (decal
splats, the Physics.raycast query) is written against the documented API and has NOT been run in a scene.
What is in it
Module (require("paintKit.modules.<name>")) | What it does | Engine calls |
|---|---|---|
config | DEFAULTS, merge (with NONE to drop a default), validate: the whole kit as one table | none |
supply | tins by pigment with a capacity and pigment slots: a satchel, a shelf, a stash | none |
design | a mural's intended picture from rows of characters and a legend, scaled to cells | none |
canvas | cells with fill and pigment: stroke, quality, sign, scrub, nextGap, serialise / restore | none |
painter | tool and pigment in hand; one tick of painting a canvas, with reasons for refusal | none |
arms | paint arms: owned, selected, cadence, paint per shot; builds a shot's projectiles (seeded scatter) or a cone pulse | none |
ballistics | projectiles under gravity in fixed sub-steps, hits through an injected query; cone, splash, arc, lobVelocity, lead | none |
pigments | tactical properties of pigments: cover / blind / fade factors and extra effects by target kind | none |
cover | cover per part of a thing, threshold effects, painted out and back, wiping, repair, save of fixed things | none |
colour | the painter's own colour: wash, washed out, recovery unseen and on friendly ground, effects | none |
impact | what a hit does: cover or a mark, surface rule, pigment effects, splash; reports offences | none |
splats | marks on the world and on moving things: merge, budgets, fading, spatial lookup, change feed, save | none |
surfaces | rule lookup for paint on a kind of surface; a field of timed and area effects | none |
engineAdapters | splatView (decal projectors, also parented to things), query (the ballistics query on Physics.raycast) | entity.spawn, @builtin::modules.decals, Physics.raycast |
tests/cases/core (canvas, supply, painter, splats, surfaces) and tests/cases/arms (arms, ballistics, cover,
colour, pigments, impact, splats on things): 62 cases of pure logic. tests/paintKit.testSuite hands the same
cases to the engine's framework.
Config schema
The header of modules/config is the schema. In short:
{
cell = 0.25,
tools = { spray = { mode = "stream", radius, coverage, tinPer, reach, range, spill, loudness, masked? } },
arms = { pistol = { mode = "pellet" | "lob" | "stream" | "cone", pellets, spread, speed, gravity, range, radius,
cover, splash?, shotsPerTin, interval, halfAngle?, loudness, heard, mount?, scope? } },
ballistics = { step, maxShots },
pigments = { white = { cover?, blind?, fade?, effects = { { effect, on = { kind }, seconds?, radius?, factor? } } } },
cover = { kinds = { guard = { parts = { visor = { capacity, effects = { { at, effect, seconds?, offence? } } } },
defaultPart, out = { part?, at, seconds?, effect?, offence? }, wipe?, persist? } } },
colour = { recover = { delay, rate, friendly }, edges, washedOut = { reviveAt, speed, canPaint, canFire, grabWindow } },
quality = { fillAt, overAt, tiers = { { name, coverage, accuracy?, overspray? }, ... } },
repaint = { keep }, scrub = { gone },
surfaces = { [kind] = { [arm | tool] | any = { effect, seconds?, radius?, offence? } } },
splats = { max, bucket, mergeWithin, maxRadius, maxPerTarget, rules = { [surface] = { life?, scrub? } } },
}
Using it: a mural
local Config = require("paintKit.modules.config")
local Supply = require("paintKit.modules.supply")
local Design = require("paintKit.modules.design")
local Canvas = require("paintKit.modules.canvas")
local Painter = require("paintKit.modules.painter")
local cfg = Config.merge(Config.DEFAULTS, myPaintConfig)
local bag = Supply.new({ capacity = 12, slots = 3 }); bag:add("ochre", 6)
local hand = Painter.new(cfg, bag, { tools = { "spray" } })
local wall = Canvas.new(cfg, Design.fromRows({ rows = { ".oo.", "oooo" }, legend = { o = "ochre" }, scale = 4 }))
local r = hand:paint(wall, dt, { u = u, v = v, distance = d, stand = feetAboveWallFoot })
if not r.ok then hud.say(r.reason) end -- "empty", "too far", "out of reach", "signed", ...
local tier = wall:sign() -- fixes it; nil if below the lowest tier
Using it: a firefight
local Arms = require("paintKit.modules.arms")
local Ballistics = require("paintKit.modules.ballistics")
local Cover = require("paintKit.modules.cover")
local Splats = require("paintKit.modules.splats")
local Surfaces = require("paintKit.modules.surfaces")
local Impact = require("paintKit.modules.impact")
local arms = Arms.new(cfg, bag, { arms = { "pistol" }, rng = seededRng }) -- same tins as the murals
local air = Ballistics.new(cfg.ballistics, query) -- query: see below
local cover, splats, field = Cover.new(cfg.cover), Splats.new(cfg.splats), Surfaces.field()
local impact = Impact.new(cfg, { cover = cover, splats = splats, field = field, query = query })
-- trigger pulled
local fired = arms:fire({ origin = muzzle, dir = aimDirection, owner = "player" })
if fired.ok then
for _, shot in fired.shots or {} do air:spawn(shot) end
if fired.cone then for _, report in impact:pulse(fired.cone) do handle(report) end end
witnesses.heard(fired.heard, fired.loudness)
end
-- every tick
arms:tick(dt)
for _, e in air:step(dt) do
if e.type == "impact" then
local report = impact:land(e.shot, e.hit) -- cover, mark, effects, offences, splash
for _, c in report.cover do
if c.type == "out" then guards.paintedOut(c.id, c.seconds) end
if c.type == "effect" and c.effect == "blind" then guards.blind(c.id, c.seconds) end
end
for _, offence in report.offences do crimes.report(offence) end
end
end
for _, e in cover:tick(dt) do guards.back(e.id) end
splats:tick(dt); view:sync(splats:drain())
Solvent coming the other way is the same machinery with a different consequence: the host flies the pursuers'
shots through its own Ballistics, and a hit on the painter calls colour:wash(amount);
colour:effects() then says how slow the painter is and whether the hands still work.
Interfaces the host provides
- Physics query (for
ballisticsandimpact):query.raycast(origin, dir, distance, exclude) -> { x, y, z, nx, ny, nz, distance, kind, target?, part?, lx?, ly?, lz? } | niland, for splash and cone arms,query.overlap(centre, radius) -> { { target, kind, part?, x, y, z } }.kindis a surface kind (cfg.surfaces) or a cover kind (cfg.cover.kinds);targetis the id of a thing.engineAdapters.query{ classify, entityOf, things }builds it onPhysics.raycast. - A seeded generator
rng() -> [0, 1)for scatter (the kit ships none, so every random number is the host's). - Where a tool points on a canvas:
(u, v)in metres from its lower-left corner, the painter's distance and the height of its feet above the wall's foot. - Drawing: canvases, shots in flight (
air:each), splats (store:drain();engineAdapters.splatView), cover meters (cover:view(id)), the screen draining withcolour:effects().drain.
Events
paintKit returns results instead of emitting events: every call that changes something returns what changed
(fire → shots or a cone, step → impacts and spent shots, land / pulse → reports, hit → cover events,
tick → things back, wash → value and washed out, stroke → touched and added, sign → tier, Field:tick →
ended effects, Splats:drain → added / changed / removed). The host turns those into its own events.
Example config for a pump gun and a blinding pigment
local cfg = Config.merge(Config.DEFAULTS, {
arms = { scatter = { mode = "pellet", pellets = 8, spread = 7, speed = 45, gravity = 9.8, range = 12,
radius = 0.14, cover = 0.14, shotsPerTin = 4, interval = 0.9, loudness = 2.5, heard = 60 } },
pigments = { white = { blind = 1.75 } },
})