Server
Last updated on
The weather contract on the server — read and change the clock and the sky.
local weather = OPX.Api.Get('weather')From server code inside opx_infinity. Nothing yields. Every change is published to all clients at once. reason is free text carried in the snapshot for diagnostics.
Ready
Whether the weather table has a usable row.
weather.Ready()Returns
boolean
Status
The current clock and sky, as a plain table (not a Result).
weather.Status()Returns
tablehour,minute,second:numberdayLengthMinutes:numbertimeFrozen,weatherFrozen:booleanweather:stringnextRollInSeconds:number?— nil while frozenrevision:number
StatusText
One-line summary, as the console sees it.
weather.StatusText()Returns
string
Presets
The live weather table. Do not modify it.
weather.Presets()Returns
table[]—{ NAME, PRESET, WEIGHT, MIN_SECONDS, MAX_SECONDS, TRANSITION_SECONDS }
SetTime
Sets the clock.
weather.SetTime(seconds, reason)Parameters
- seconds:
number- Seconds since midnight; wrapped into one day.
- reason?:
string
Returns
Result— errorinvalid_timewhensecondsis not a finite number
weather.SetTime(22 * 3600, 'night event') -- 22:00SetTimeFrozen
Holds or releases the clock.
weather.SetTimeFrozen(frozen, reason)Parameters
- frozen:
boolean - reason?:
string
SetDayLength
Changes how many real minutes a game day lasts.
weather.SetDayLength(minutes, reason)Parameters
- minutes:
number- 1..10080; under 12 is refused.
- reason?:
string
Returns
Result— errorsinvalid_day_length,day_too_short
SetWeather
Crosses to a weather and reschedules the next roll.
weather.SetWeather(name, transitionSeconds, reason)Parameters
- name:
string- A row's
NAMEorPRESET.
- A row's
- transitionSeconds?:
number- 0..300. Default: the row's
TRANSITION_SECONDS.
- 0..300. Default: the row's
- reason?:
string
Returns
Result— errorsno_presets,unknown_preset,invalid_transition
local set = weather.SetWeather('rain', 30, 'storm event')
if not set.ok then print(set.error) endSetWeatherFrozen
Holds or releases the roll schedule. Unfreezing schedules a new roll.
weather.SetWeatherFrozen(frozen, reason)Parameters
- frozen:
boolean - reason?:
string
Roll
Picks a different row by weight and applies it.
weather.Roll(reason)Parameters
- reason?:
string
Returns
Result