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.
| Side | both |
| Requires | none |
| Contract | weather v1 — server, client |
| Config | config/weather.lua (shared) |
| Data | none (reload carry-over only) |
Commands
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.
| Key | Default | Effect |
|---|---|---|
enabled | true | false switches the module off; the engine then runs its own clock and sky on each client. |
DAY_LENGTH_MINUTES | 180 | Real minutes per game day. 180 matches the engine. |
START_TIME | { HOUR = 12, MINUTE = 0, SECOND = 0 } | Clock at server start. |
TIME_FROZEN | false | Start with the clock held. |
WEATHER_FROZEN | false | Start 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. |
WEATHER | 8 rows | The roll table: sunny, lightclouds, cloudy, rain, heavyclouds, fog, pollution, sandstorm. |
COMMANDS | see 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. |
{ 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;0never rolls.MIN_SECONDS,MAX_SECONDS: real seconds before the next roll.TRANSITION_SECONDS: crossfade length, 0..300.
Refusal codes
| Code | Meaning | Locale key |
|---|---|---|
invalid_time | Not HH:MM[:SS], or out of range. | weather.error.invalidTime |
invalid_day_length | Not a number, or outside 1..10080. | weather.error.invalidDayLength |
day_too_short | Faster than 120 game seconds per real second (under 12 minutes a day). | weather.error.dayTooShort |
unknown_preset | Not a NAME or PRESET in the table. | weather.error.unknownPreset |
invalid_transition | Not a number in 0..300. | weather.error.invalidTransition |
no_presets | The table has no usable row. | weather.error.noPresets |