Esc to clear, Enter to open the best match, click an export to open it in its page
World

Time & Weather API

Exports for the world's clock and weather, and for per-player layers. New to them? Read Time & Weather.

Reading

GetTime()SERVER#

The server time, exact at the moment you call it.

Returns: number hour, number minute
GetWeather()SERVER#

The server weather, in upper case.

Returns: string
GetTimeScale()SERVER#

The time scale multiplier.

Returns: number
IsTimeFrozen()SERVER#

Whether the world's clock is frozen.

Returns: boolean
IsBlackout()SERVER#

Whether the city is blacked out.

Returns: boolean

Setting

Each change reaches every client at once and is saved.

SetTime(hour, minute)SERVER#

Sets the time and fires whip_core:time:changed { hour, minute }. Out-of-range values wrap, each on its own (25:61 is 01:01).

ParamTypeDescription
hournumber0–23
minutenumber?0–59, default 0
Returns: true, or false, reason for a value that isn't a number
SetWeather(weather)SERVER#

Sets the weather and fires whip_core:weather:changed { weather }.

ParamTypeDescription
weatherstringOne of Config.WeatherTypes, any case
Returns: true, or false, reason ('Invalid weather type', or not a string)
SetTimeFrozen(frozen)SERVER#

Freezes or unfreezes the clock for everyone, and fires whip_core:time:freezeChanged { frozen }.

ParamTypeDescription
frozenbooleantrue freezes
Returns: true
SetBlackout(blackout)SERVER#

Turns every artificial light off or back on.

ParamTypeDescription
blackoutbooleantrue = blackout
Returns: true
SetTimeScale(scale)SERVER#

Sets how fast the clock runs: 1.0 is normal (48 min real = 24 h game), 2.0 twice as fast.

ParamTypeDescription
scalenumber0.0–10.0, clamped
Returns: true, or false, reason for a scale that isn't a number

Layers

A layer is yours: another resource can't replace or clear it, and it comes off when your resource stops. Numbers must be numbers and weather one of Config.WeatherTypes.

SetPlayerWeatherLayer(source, name, opts)SERVER#

Pushes a layer onto one player.

ParamTypeDescription
sourcenumberPlayer server id
namestringAt most 64 characters. The player sees it as 'server:' .. name, apart from client layers
optstable|nil{ priority?, hour?, minute?, weather?, frozen?, blackout? }, nothing else; nil clears
Returns: true, or false, reason
ClearPlayerWeatherLayer(source, name)SERVER#

Removes one of your layers from one player.

Returns: true, or false, reason
GetPlayerWeatherLayers(source)SERVER#

The layers the server pushed to this player, not the ones the client set itself (such as its zone's): the client's GetWeatherLayers has the whole picture.

Returns: { [name] = opts }
SetWeatherLayer(name, opts)CLIENT#

Adds or replaces a layer on this client; nil opts removes it.

ParamTypeDescription
namestringUnique per source, e.g. 'zone:swamp'
optstable|nil{ priority?, hour?, minute?, weather?, frozen?, blackout? }
Returns: true, or false, why ('Invalid weather type', 'layer "x" belongs to …')
ClearWeatherLayer(name)CLIENT#

Removes one of your layers; the others stay.

Returns: true, or false, why (none, or another resource's)
GetWeatherLayers()CLIENT#

Every active layer in priority order, and which owns each field: for debugging a stack.

Returns: { layers = { {name, priority} }, owners = { weather = 'zone:swamp', hour = 'server', ... } }

Client#

What this player sees, layers included.

GetTime()CLIENT#

The time as the local player sees it.

Returns: number hour, number minute
GetWeather()CLIENT#

The weather as the local player sees it.

Returns: string
IsTimeFrozen()CLIENT#

Whether the clock is frozen for this player, by the server or by a layer.

Returns: boolean
IsTimeOverridden()CLIENT#

Whether any layer is active for this player; GetWeatherLayers says which.

Returns: boolean