Rain, thunderstorms, snow, fog and the cloud cover, with presets that fade the map's weather in and out (since API 4).
The weather of the hunt: rain (streaks around the hunter slanted by the wind, splashes, a darker and wetter
light, its sound), thunderstorms (lightning that lights up the sky and the land, a bolt, thunder after a delay that
grows with the distance), snow (Ice Age's snowfall, now in Dinosaur Hunter too), fog and a cloud cover
that hides the sky. weather.set(preset, seconds) fades all of it, and the map's own world.weather fields (fog,
sky, sun and shadow colours, clouds) with it, so a hunt can turn stormy over a minute and clear up again.
Presets are made from the map's own weather (a night map stays dark): map (the map's own, as loaded), clear (the
same without rain or snow), overcast, fog, rain, storm, snow, blizzard. Everything is undone when your mod
unloads, like world.weather; a new map starts with its own weather. The weather guide has
the details and an example.
Fades the weather to a preset (or to the values of a table) over seconds. A table without preset changes only the values it names; with one, it is the preset with those values changed (current().preset is "custom" then). In a hunt: the weather belongs to the loaded map (outside a hunt it raises an error).
Parameter
Type
preset
string|table
a preset's name, or a table: preset (optional: the start) and any of fogStart, fogEnd (units), skyColor, sunColor, shadowColor, skyPlaneColor (Color), cloudsSpeed, cover (0-1), rain (0-1), snow (0-1), lightning (strikes per minute, 0-60)
secondsoptional
number
the fade, 0-3600 (default 0: at once)
on("hunt_start", function()
weather.set("overcast") -- at oncetimer.after(30, function() weather.set("storm", 60) end) -- the storm rolls in over a minuteend)
-- your own look: the rain preset with a green sky and less rainweather.set({preset = "rain", rain = 0.4, skyColor = "#405848"}, 20)
The weather now: the last preset set (map before any), the seconds left of the fade, every value as it is at this moment and target, where the fade goes. The colours are the weather's own; world.weather reads what is drawn (with the rain's light and the lightning's flash on top).
Back to the map's own weather (the map preset), at once or in a fade. In a hunt: the weather belongs to the loaded map (outside a hunt it raises an error).
The rain: weather.rain() reads it, weather.rain(0.8, 20) fades it. Rain on a bright sky brings its own darker light and clouds; the presets rain and storm come with their own sky.
Random lightning: strikes per minute (on average), each anywhere from about a hundred metres to three kilometres away. The lightning event comes before each.
A lightning strike now: the flash, the bolt from the clouds, and its thunder after distance / 128 / 343 seconds (sound at 343 m/s). Works in any weather. In a hunt: the weather belongs to the loaded map (outside a hunt it raises an error).
Parameter
Type
xoptional
number
where (default: a random place around the hunter)
zoptional
number
Returns
table|nil
{x, z, distance, delay}: distance in units, delay = seconds until the thunder; nil when a lightning handler cancelled it
local x, _, z = player.pos()
local fx, fz = player.forward()
weather.strike(x + fx * 60000, z + fz * 60000) -- 470 m ahead: thunder 1.4 s later