OPX//77
opx_infinityweather

weather

Last updated on

One server clock and one sky for everyone, with staff commands to set, roll and freeze both.

The server runs the time of day at a configured day length, rolls the next weather from a weighted table and sends a snapshot to every client, which applies it and corrects drift. State survives a resource reload, not a server restart.

Sideboth
Requiresnone
Contractweather v1 — server, client
Configconfig/weather.lua (shared)
Datanone (reload carry-over only)

Commands

CommandAccessArgumentsEffect
/opx.weathereveryone—Time, day length, weather, next roll, revision.
/opx.weather.presetseveryone—The weather table: name, preset, weight, duration, transition.
/opx.weather.setACL command.opx.weather.set<preset> [transitionSeconds]Crosses to a preset (NAME or PRESET). Transition 0..300 s, default the row's TRANSITION_SECONDS.
/opx.weather.nextACL command.opx.weather.next—Rolls the weighted table now.
/opx.weather.freezeACL command.opx.weather.freezeon|offHolds or releases the roll schedule.
/opx.timeACL command.opx.timeHH:MM[:SS]Sets the clock.
/opx.time.freezeACL command.opx.time.freezeon|offHolds or releases the clock.
/opx.time.lengthACL command.opx.time.length<minutes>Real minutes per game day, 1..10080; under 12 is refused (day_too_short).

Registered with OPX.Command.Register: the chat box suggests them and they can be aliased. Names and restriction come from COMMANDS. A player may run each once per 2 seconds. A report (/opx.weather, /opx.weather.presets) comes back as a chat read-back (OPX.CommandResult); an action's answer comes back as a toast (OPX.CommandNotice). On the console the answer is printed.

Configuration

config/weather.lua sets OPX.Config.MODULES.weather.

KeyDefaultEffect
enabledtruefalse switches the module off; the engine then runs its own clock and sky on each client.
DAY_LENGTH_MINUTES180Real minutes per game day. 180 matches the engine.
START_TIME{ HOUR = 12, MINUTE = 0, SECOND = 0 }Clock at server start.
TIME_FROZENfalseStart with the clock held.
WEATHER_FROZENfalseStart with the roll schedule held.
INITIAL_WEATHER'sunny'Weather at start, held 180 s before the first roll. Unknown names fall back to the first row.
WEATHER8 rowsThe roll table: sunny, lightclouds, cloudy, rain, heavyclouds, fog, pollution, sandstorm.
COMMANDSsee Commands{ KEY = { NAME, RESTRICTED } } for STATUS, PRESETS, SET, NEXT, FREEZE, TIME, TIME_FREEZE, DAY_LENGTH. An empty NAME turns the command off. SET to DAY_LENGTH stay restricted unless RESTRICTED = false.
config/weather.lua — one WEATHER row
{ NAME = 'rain', PRESET = '24h_weather_rain', WEIGHT = 10,
  MIN_SECONDS = 600, MAX_SECONDS = 1200, TRANSITION_SECONDS = 60 },
  • NAME: what staff type and the state stores. Add rows freely; do not rename.
  • PRESET: the engine weather preset.
  • WEIGHT: relative chance of being rolled; 0 never rolls.
  • MIN_SECONDS, MAX_SECONDS: real seconds before the next roll.
  • TRANSITION_SECONDS: crossfade length, 0..300.

Refusal codes

CodeMeaningLocale key
invalid_timeNot HH:MM[:SS], or out of range.weather.error.invalidTime
invalid_day_lengthNot a number, or outside 1..10080.weather.error.invalidDayLength
day_too_shortFaster than 120 game seconds per real second (under 12 minutes a day).weather.error.dayTooShort
unknown_presetNot a NAME or PRESET in the table.weather.error.unknownPreset
invalid_transitionNot a number in 0..300.weather.error.invalidTransition
no_presetsThe table has no usable row.weather.error.noPresets

On this page