▣
module · drop-in viewer
fleet
The vehicles in Wren's life: her own van, whatever she has borrowed, and what
by·posted 11d ago
What it does
fleet
The vehicles in Wren's life: her own van, whatever she has borrowed, and what
stands in the garages.
Any vehicle in the city can be borrowed; only the van is hers and only the van keeps upgrades. A garage opens
in a district once its colour reaches Economy.garages.opensAt and holds ONE borrowed vehicle, with the paint
that was on it. This module is the bookkeeping: what she is driving, what is stored where, what each vehicle
looks like to a Warden (type, colour, plate), and what its type lets her do (content.vehicles).
local Fleet = require("metropolisGame.logic.fleet")
local fleet = Fleet.new(Vehicles, Economy.garages, hub?) -- content.vehicles, content.economy.garages
fleet:grantVan({ colour = "ochre", plate = "VR 0417" }) -- the van becomes hers (Borrowed Wheels)
fleet:hasVan()
fleet:board("car7", { type = "finch", colour = "blue", plate = "VR 1123", state = "parked" })
-- she took the wheel of a vehicle: returns its record { id, type, colour, plate, owned, def }
fleet:alight() -- she got out (the vehicle stays known as `last`)
fleet:driving() -- the record she is at the wheel of, or nil
fleet:type("car7") fleet:def("finch") -- a known vehicle's type; a type's content entry
fleet:appearance() -- { ["vehicle.kind"], ["vehicle.colour"], ["vehicle.plate"] } while driving, else {}
fleet:repaint("car7", "white") fleet:replate("car7", "VR 9001")
fleet:garages(colourOf) -- { { district, open, vehicle = record | nil } } district order
fleet:store("old_quay", "car7", colourOf) -- ok, why ("closed" | "full" | "own" | "unknown" | "driving")
fleet:retrieve("old_quay") -- the record, out of the garage (the host spawns it), or nil
fleet:forget("car7") -- abandoned for good, impounded or wrecked
fleet:serialise() fleet:restore(data)
Hub events: "boarded" { vehicle, type, owned }, "alighted" { vehicle }, "stored" { district, vehicle },
"retrieved" { district, vehicle }, "vanGranted" {}.
The interface is documented in the header of init.luau; this file repeats it for the asset browser.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.