Skip to content

SetWeatherChances

How often each kind of weather comes up in the server’s rotation, and how long a sky stays.

The server rolls the sky for everyone ([world] weather "", or after SetWeather("")): at every roll each kind comes up by its weight - relative numbers, so {clear = 70, showers = 25, storm = 5} is a storm about one sky in twenty. The kinds are clear, fair, cloudy, overcast, showers, drizzle, storm, dry_storm (the other preset names - sunny, rain, fog - are aliases and add up); a kind left out, or at 0, never comes up. A key may also be one of the level’s own profiles, such as a kind’s _B variant (Weather lists them with the game’s own chances). A rolled sky holds minHours to maxHours of game time (3 to 5 by default; the same sky may come up again and simply stays), then the next is rolled. Every client follows the rolled sky and its rain, and a player who joins gets the sky up now.

A sky up now that the new chances leave out goes at once (blended in over two minutes); one they keep stays for what is left of its hold. While SetWeather names a sky the chances wait for the rotation. nil (or {}) hands the rotation back to the server’s own mix. An admin’s /weather chances shows them.

SetWeatherChances(chances [, minHours, maxHours])
Parameter Type
chances table {kind = weight, ...} - weights of 0 or more; nil = the server’s own mix
minHours number the shortest a rolled sky stays, in game hours (above 0, up to 168); nil = 3 to 5 (optional)
maxHours number the longest, not below minHours; nil = minHours (optional)

true, or false, reason - the reason as a person reads it (an unknown kind, a weight below 0, every weight 0, a hold out of range)

-- a dry summer: mostly clear, a little rain, no storms; a sky lasts 2 to 6 game hours
local ok, why = SetWeatherChances({clear = 40, fair = 35, cloudy = 15, showers = 10}, 2, 6)
if not ok then Log("weather: " .. why) end

GetWeatherChances · SetWeather · SetRain · the The world - clock, weather, terrain, the navmesh, the geometry group of the index