Clock
The ship’s clock. It tracks the time of day, the day count, and the sun’s position: everything a script needs for day-night timing and solar tracking.
Access: get_component("clock") · Like every component, exposes .id (stable id) and .name (display name).
Methods
Section titled “Methods”.get_time()
Section titled “.get_time()”Current time as a 3-element list [hours, minutes, seconds] in 24-hour format. Index with t[0], t[1], t[2]. Use for time-of-day branches or to wait for specific hours.
Returns: List [hours, minutes, seconds]
.get_day()
Section titled “.get_day()”Current day number: starts at 1 and increments when the in-world clock rolls past midnight. Use for daily-budget logic (e.g. reset counters at the start of each day) or to detect day transitions for machines like the Heat Generator whose state changes per day.
Returns: Number (day count)
.get_time_of_day()
Section titled “.get_time_of_day()”Current daylight phase as a string: "dawn", "day", "dusk", or "night". This is the simulation phase used by solar/day-night logic; the header may further label "day" as Morning/Afternoon/Evening for flavor.
Returns: String: dawn / day / dusk / night
.get_elevation()
Section titled “.get_elevation()”Sun’s elevation above the horizon (0-90 degrees). 0 at night, rises to 90 at solar noon (equator), back to 0 at dusk. Solar panels peak when their tilt complements the current elevation.
Returns: Number (0-90 degrees)
.tick()
Section titled “.tick()”Deterministic simulation tick since save start. At normal speed the simulation grants a fresh script step budget every tick (10 ticks/sec, so one tick is 0.1 simulation seconds). Use tick deltas for profiling script timing instead of wall-clock milliseconds.
Returns: Integer simulation tick since save start
.elapsed_seconds()
Section titled “.elapsed_seconds()”Elapsed simulation seconds since save start. This is the same time base that sleep(seconds) waits against, not browser wall-clock time.
Returns: Number (elapsed simulation seconds)
.elapsed_game_hours()
Section titled “.elapsed_game_hours()”Elapsed world-clock hours since save start. Useful for rate calculations and logs that should follow the compressed day/night cycle instead of real seconds.
Returns: Number (elapsed world-clock hours)
.real_seconds_per_hour()
Section titled “.real_seconds_per_hour()”Number of real seconds in one world-clock hour. The day cycle compresses 24 world-clock hours into a fixed real-time window, so sleep(clock.real_seconds_per_hour()) waits exactly one world-clock hour and multiplying by 24 waits a full day. Lets scripts express world-time delays without hardcoding the conversion.
Returns: Number (real seconds per world-clock hour)
See also
Section titled “See also”- Solar Generator: the main consumer of
get_elevation() - Built-in Functions:
sleep()uses real seconds, this clock converts