Painted Metropolis
README.md
theft
Taking a vehicle that is not yours: what it costs, who calls it in, and how long
the vehicle stays hot.
Taking a vehicle is judged by the state it was in (cfg.theft.takes[state]): a parked car nobody saw you take is
no offence at all until its owner misses it; an occupied one has its own witness, who reports within seconds;
a pursuer's own vehicle is known at once. A report, when it lands, makes the vehicle HOT: its kind, colour and
plate are in the description the pursuers hold, so driving it draws eyes until it is abandoned, resprayed or
replated. Vehicles the config lists under `lawful` do the opposite while they are not hot: nobody looks twice.
local Theft = require("~.modules.theft")
local theft = Theft.new(cfg.theft)
local r = theft:take({ id = "car7", kind = "saloon", colour = "blue", plate = "VR 1123", state = "occupied" },
{ witnessed = false, x = 10, z = 4 })
-- { offence = "takeOccupied" | nil, the offence to add now (nil: nobody saw and nobody was in it)
-- reportIn = 8 | nil, seconds until the owner's report lands (nil: no report coming)
-- appearance = { ["vehicle.kind"] = "saloon", ["vehicle.colour"] = "blue", ["vehicle.plate"] = "VR 1123" } }
local landed = theft:tick(dt)
-- { { vehicle = "car7", offence = "stolenVehicle", x, z, appearance } } owners' reports that arrived: add
-- the offence and note the appearance on the description (the host forwards them to the director)
theft:isHot("car7") -- reported and still on the list
theft:pending("car7") -- seconds until its report lands (nil when none is coming)
theft:changed("car7", { colour = "red" }) -- resprayed or replated: off the hot list (returns true if it was hot)
theft:release("car7") -- given back, impounded or destroyed: forgotten entirely
theft:fillFactor(vehicle) -- the factor on being noticed while driving it: cfg.hot.fillFactor when hot,
-- cfg.lawful[kind].fillFactor when it is that kind and not hot, else 1
theft:list() -- { { vehicle, kind, colour, plate, hot, reportIn } } id order (for a garage screen)
theft:serialise() theft:restore(data)
Config (cfg.theft):
takes[state] = { offence?, witnessedOffence?, report = { delay, offence }? }
offence: added at once whoever sees (the owner is in it); witnessedOffence: added only when seen;
report: the owner's call, `delay` seconds after the taking
hot = { fillFactor, cools } noticed faster in a hot vehicle; a hot vehicle unseen for `cools` seconds
drops off the list (nil: never)
lawful[kind] = { fillFactor } vehicles nobody looks at twice while they are not hot (a taxi)
The interface is documented in the header of init.luau; this file repeats it for the asset browser.