Skip to main content

WeatherAct, WeatherProperty and TornadoState

These tables are used to control the weather from the server: WeatherAct names one-off weather actions (spawn or remove the tornado), WeatherProperty names a weather setting to change (the tornado's position and state, and the look of the clouds), and TornadoState holds the states the tornado can be put in.

Available on: Server, Client (the tables exist on both sides, but only the server's Weather functions take them)

Values​

WeatherAct​

Used by Weather.SyncAct(act, ...) (server). The extra arguments depend on the act. Any other value raises the Lua error invalid weather act <n>. The act is sent to every player in the server at that moment; the server does not remember it, so players who join later don't get it.

NameValueMeaningExtra arguments
WeatherAct.SpawnTornado0Spawn the world's tornado.position (vec3, where it forms), formTime (number, how long it takes to form)
WeatherAct.DespawnTornado1Remove the world's tornado.time (number, how long it takes to go away)

WeatherProperty​

Used by Weather.SyncProperty(property, value) (server). The type of value depends on the property. Any other property value raises the Lua error invalid weather property <n>. Like acts, properties are sent to the players in the server at that moment only.

NameValueValue typeMeaning
WeatherProperty.TornadoPosition0vec3Move the tornado to this position (needs a spawned tornado).
WeatherProperty.TornadoState1TornadoStatePut the tornado in this state (needs a spawned tornado).
WeatherProperty.CloudsAmbientSaturation2numberColor saturation of the ambient light on the clouds.
WeatherProperty.CloudsAmbientIntensity3numberIntensity of the ambient light on the clouds.
WeatherProperty.CloudsSunIntensity4numberIntensity of the sunlight on the clouds.
WeatherProperty.CloudsScatteringCoeff5numberHow much light the clouds scatter.
WeatherProperty.CloudsExtinctionCoeff6numberHow much light the clouds absorb.
WeatherProperty.CloudsForwardAnisoScattering7numberForward scattering of light through the clouds (the bright glow around the sun).
WeatherProperty.CloudsBackwardAnisoScattering8numberBackward scattering of light off the clouds.
WeatherProperty.CloudsMaxLightConeDistance9numberThe maximum distance light is traced through the clouds when shading them.
WeatherProperty.CloudsMaxPrecipitationDarkeningFactor10numberHow much rain clouds are darkened at most.
WeatherProperty.CloudsAmbientSkylightColor11vec3Color (red, green, blue) of the ambient sky light on the clouds.
WeatherProperty.CloudsDirectSunlightColor12vec3Color (red, green, blue) of the direct sunlight on the clouds.
WeatherProperty.CloudsLayerHeightLow13numberHeight of the bottom of the cloud layer.
WeatherProperty.CloudsLayerHeightHigh14numberHeight of the top of the cloud layer.

Every number and every vec3 component must be finite, or the call raises a Lua error.

TornadoState​

The states of the world's tornado, used as the value of WeatherProperty.TornadoState. A value outside 0..6 raises the Lua error invalid tornado state <n>.

NameValueMeaning
TornadoState.Forming0The tornado is forming.
TornadoState.Moving1The tornado is moving.
TornadoState.Stopping2The tornado is slowing down to a stop.
TornadoState.Stopped3The tornado stands still.
TornadoState.Dissipating4The tornado is dissipating.
TornadoState.Disappearing5The tornado is disappearing.
TornadoState.WaitingBeforeResetting6The tornado is gone and waits before it resets.

Example

-- server: an admin command that spawns the tornado at the sender, stops it after a minute, then removes it
Net.AddEvent("tornadoHere", function()
local client = Net.Sender()
if not client:HasAcl(AclLevel.Admin) then
return
end

local player = client:GetPlayer()
if not player then
return
end

Weather.SyncAct(WeatherAct.SpawnTornado, player:GetPosition(), 5.0)
Weather.SyncProperty(WeatherProperty.CloudsDirectSunlightColor, vec3(1.0, 0.6, 0.4))

Timer.Set(function()
Weather.SyncProperty(WeatherProperty.TornadoState, TornadoState.Stopped)
end, 60000, 1)

Timer.Set(function()
Weather.SyncAct(WeatherAct.DespawnTornado, 5.0)
end, 70000, 1)
end)