Wax

Time, weather and the prospect

Read the game's clock, the weather on your character and the prospect you are in, and hear when a player joins or leaves.

Three names tell you about the session you are in: game.Time, game.Weather and game.Prospect. Each field asks the game when you read it, and is nil while you are not in a prospect.

init.lua
local hud = ui.Overlay({ title = "Prospect", anchor = "top-right", width = 240 })
local clock = hud:Field("Time", "")
local weather = hud:Field("Weather", "")

task.every(1, function()
    if not game.InProspect then return end
    clock:Set((game.Time.Clock or "?") .. "  " .. (game.Time.Phase or ""))
    weather:Set(game.Weather.Current or "Clear")
end)

The time of day

FieldWhat it is
game.Time.HourThe hour of the game's clock, from 0 to 23.
game.Time.MinuteThe minute, from 0 to 59.
game.Time.ClockThe time as text, such as "7:05" or "19:30".
game.Time.Phase"Morning" from 6, "Day" from 10, "Afternoon" from 14, "Night" from 18 to 6.
game.Time.IsNighttrue while the phase is "Night".
game.Time.ScaleThe speed the game's clock is set to. 1 as the game sets it.

The game's clock does not run evenly. It runs faster at night. So read Hour, and do not work the time out from seconds.

game.Time.HourChanged fires with the new hour and the one before. It is looked at twice a second, and only while something is connected.

init.lua
game.Time.HourChanged:Connect(function(hour)
    if hour == 18 then
        ui.Notify("Night is coming.", { kind = "warn" })
    end
end)

Set the time

The clock can be moved forward to a time later the same day.

init.lua
local window = ui.Window({ title = "Clock", width = 260, height = 130 })

window:Button("Skip to noon", function()
    local hour = game.Time.Hour
    if game.IsHost and hour and hour < 12 then
        game.Time:Set(12)
    end
end)
  • game.Time:Set(hour, minute) gives back true when the clock says that time afterwards.
  • The game's clock only goes forward within a day. An earlier time raises an error that says what the clock shows. Going on to the next day is not in this version.

The weather

FieldWhat it is
game.Weather.CurrentThe weather event your character is in, such as "T3_Conifer_Rain". nil in clear weather.
game.Weather.TierHow heavy it is: 0 for the lightest up to 6 for the heaviest. nil in clear weather.
game.Weather.IsStormtrue while your character is in weather of tier 1 or more.
game.Weather.ActiveEvery weather event running on the map. Only the host has it.

The names are rows of the game's table D_WeatherEvents.

game.Weather.Changed fires when the weather on your character is another event than before. Your function gets the new event and the one before, with nil for clear weather. It is looked at once a second.

init.lua
game.Weather.Changed:Connect(function(current)
    if game.Weather.IsStorm then
        ui.Notify("A storm: " .. tostring(current), { kind = "warn" })
    end
end)

game.Weather.Active is a list with one entry for each biome an event runs in: Event, Biome, Tier and Since. It reads each of them, so do not read it every frame. It is nil when you are a guest in someone else's game.

Wax reads the weather. Starting or stopping it is not in this version.

The prospect

local prospect = game.Prospect
print(prospect.Name, prospect.Difficulty, prospect.Elapsed)
FieldWhat it is
NameThe prospect's name in the game's data, such as "Tier1_Forest_Recon_0".
MissionThe mission's name in the game's data, or nil when the prospect has none.
Difficulty"Easy", "Medium", "Hard" or "Extreme".
ElapsedHow long the prospect has run, in seconds.
DurationHow long it lasts in all, in seconds.
RemainingDuration less Elapsed. nil when the game gives the prospect no duration.
IsOpenWorld, IsOutpostThe game's own marks for an open world and an outpost.
Id, SeedThe game's id and seed for this prospect.

Players who join and leave

game.Players has two signals for the session:

init.lua
game.Players.Joined:Connect(function(player)
    ui.Notify((player.PlayerName or "Somebody") .. " joined.")
end)

game.Players.Left:Connect(function(player, name)
    ui.Notify((name or "Somebody") .. " left.")
end)
  • The players are looked at once a second, and only while something is connected to one of the two.
  • Joined does not fire for the players who are there when you connect.
  • After Left, the player's Instance can no longer be used. You can still compare it with one you kept.
  • Neither fires for what a map change brings or takes away.

A player from game.Players:GetPlayers() or from Joined has three fields:

FieldWhat it is
player.PlayerNameThe player's name. nil while the game has not said.
player.IsHosttrue for the player who hosts the session.
player.CharacterThe character the player controls right now, or nil.

These two signals have only been run with one player in the session. A second player joining has not been seen yet.

Every field is listed in the Time, weather and the prospect reference.

On this page