Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 0a0b119f-a…

clock

The city's day: hours that pass, and the moments other systems wait for.

byzero-proxy @ DESKTOP-DB3UJOJ·posted 11d ago
What it does

clock

The city's day: hours that pass, and the moments other systems wait for.

  local Clock = require("metropolisGame.logic.clock")
  local clock = Clock.new({ dayMinutes = 36, start = 5.5, dawn = 6, dusk = 20, blend = 1 }, hub?)
  clock:tick(dt)            -- real seconds; returns the hours crossed this tick, e.g. { 6 } (empty most ticks)
  clock.hour   clock.day    -- 0..24 and days since the start (0-based)
  clock:weekday()           -- 1..7 (day 0 is weekday 1)
  clock:phase()             -- "dawn" | "day" | "dusk" | "night"
  clock:isNight()           clock:text() -> "06:15"
  clock:skipTo(22)          -- rest until an hour (crosses the hours between; returns them)
  clock:set(hour)           -- a mission sets the scene (no hours are "crossed")
  clock:secondsUntil(6)     -- real seconds until an hour next comes round
  clock:serialise()   clock:restore(data)

Several players, one clock (the shared-anchor model): nobody ticks. The clock's owner publishes an ANCHOR record
and every peer computes the hour from it and a timeline they all agree on, so nothing drifts:
  local record = clock:anchor(sharedNow)    -- { t0, total0, dayMinutes } for the host to sync (owner only)
  clock:follow(record, sharedNow)           -- every peer, every tick: advances to where the record says (hours
                                            --   crossed fire as usual); returns the hours crossed
  clock.moved                               -- true after skipTo / set / restore: the owner publishes a new anchor

Hub events: "hour" { hour, day }, "dayPassed" { day } (at midnight).

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

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

metropolisGame.logic.clock — the city's day: hours that pass, and the moments other systems wait for. local Clock = require("metropolisGame.logic.clock") local clock = Clock.new({ dayMinutes = 36, start = 5.5, dawn = 6, dusk = 20, blend = 1 }, hub?) clock:tick(dt) -- real seconds; returns the hours crossed this tick, e.g. { 6 } (empty most ticks) clock.hour clock.day -- 0..24 and days since the start (0-based) clock:weekday() -- 1..7 (day 0 is weekday 1) clock:phase() -- "dawn" | "day" | "dusk" | "night" clock:isNight() clock:text() -> "06:15" clock:skipTo(22) -- rest until an hour (crosses the hours between; returns them) clock:set(hour) -- a mission sets the scene (no hours are "crossed") clock:secondsUntil(6) -- real seconds until an hour next comes round clock:serialise() clock:restore(data) Several players, one clock (the shared-anchor model): nobody ticks. The clock's owner publishes an ANCHOR record and every peer computes the hour from it and a timeline they all agree on, so nothing drifts: local record = clock:anchor(sharedNow) -- { t0, total0, dayMinutes } for the host to sync (owner only) clock:follow(record, sharedNow) -- every peer, every tick: advances to where the record says (hours -- crossed fire as usual); returns the hours crossed clock.moved -- true after skipTo / set / restore: the owner publishes a new anchor Hub events: "hour" { hour, day }, "dayPassed" { day } (at midnight).

new(cfg: any, hub: any?) → any

argtypedescription
cfgany
hubany?

advance(self: any, hours: number) → void

argtypedescription
selfany
hoursnumber

tick(dt: number) → void

Advance by real seconds.

argtypedescription
dtnumber

anchor(sharedNow: number) → any

The anchor record for the present moment at a shared time.

argtypedescription
sharedNownumber

follow(record: any, sharedNow: number) → void

Advance to where an anchor record says the clock is at a shared time. Returns the hours crossed.

argtypedescription
recordany
sharedNownumber

skipTo(hour: number) → void

Jump forward to the next time it is `hour`. Returns the hours crossed.

argtypedescription
hournumber

set(hour: number) → void

argtypedescription
hournumber

secondsUntil(hour: number) → number

argtypedescription
hournumber

phase( ) → string

weekday( ) → number

isNight( ) → boolean

text( ) → string

serialise( ) → any

restore(data: any) → void

argtypedescription
dataany

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.