openOMSI GitHub Discord
Plugin API reference

Docs / Plugins / Plugin API reference

Weather

1 min readEdit this pagedocs/PLUGIN_API.md

On this page
  1. omsi.weather.get
  2. omsi.weather.precipitation
  3. omsi.weather.preset
  4. omsi.weather.presets
  5. omsi.weather.set
  6. omsi.weather.temperature
  7. omsi.weather.visibility
  8. omsi.weather.wetness
  9. omsi.weather.wind

omsi.weather.* reads the weather and changes it as the game menu does. Changes are refused in a LAN game as a client, and while the weather follows a real station.

omsi.weather.get#

omsi.weather.get() → table or nil

The weather now: {name, visibility (m), wind_direction (°), wind_speed (m/s), temperature (°C), humidity (%), absolute_humidity (g/m³), pressure (hPa), clouds, cloud_base (m), precipitation ("none", "rain", "snow"), precipitation_rate (0..1), snow_cover, snow_on_road, wetness (the roads, 0..1), changing, locked} (locked: it follows a real weather station and cannot be set).

Since 0.2.22.

omsi.weather.precipitation#

omsi.weather.precipitation() → kind, rate

"none", "rain" or "snow", and how hard (0 to 1).

Since 0.2.22.

omsi.weather.preset#

omsi.weather.preset(file, [seconds]) → true, or false and the reason

Changes to a weather file (as weather.presets names it; "": the map's own, changing with the day) over seconds (default 1).

Parameters: file string; seconds number, optional.

Since 0.2.22. Permission: world_write.

Lua
omsi.weather.preset(omsi.weather.presets()[1].file, 60)

omsi.weather.presets#

omsi.weather.presets() → list of tables

The weather files installed: {file, name}.

Since 0.2.22.

omsi.weather.set#

omsi.weather.set(values) → true, or false and the reason

Changes the weather as the game menu's sliders do, any of visibility

wind_direction wind_speed temperature pressure
clouds
"-1" none, "Cumulus 1".."3", "Overcast 1"
cloud_base
precipitation
"none", "rain", "snow"
precipitation_rate
0..1
snow_cover snow_on_road wetness

the rest stays. Held to the game's ranges, refused in a LAN game as a client or while the weather follows a station.

Parameters: values table.

Since 0.2.22. Permission: world_write.

Lua
local ok, why = omsi.weather.set({ precipitation = "snow", precipitation_rate = 0.5, temperature = -3 })

omsi.weather.temperature#

omsi.weather.temperature() → number or nil

The air temperature, °C.

Since 0.2.22.

omsi.weather.visibility#

omsi.weather.visibility() → number or nil

How far one sees, metres.

Since 0.2.22.

omsi.weather.wetness#

omsi.weather.wetness() → number or nil

How wet the roads are, 0 (dry) to 1.

Since 0.2.22.

omsi.weather.wind#

omsi.weather.wind() → direction, speed

The wind: where it comes from (degrees) and its speed (m/s).

Since 0.2.22.

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open