-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweather.lua
More file actions
49 lines (40 loc) · 1.28 KB
/
Copy pathweather.lua
File metadata and controls
49 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- weather.lua
-- Implements weather-related standards and /weather.
-- Make proper values out of descriptors.
local WeatherNames =
{
["sunny"] = wSunny,
["rainy"] = wRain,
["stormy"] = wStorm,
}
-- Strings displayed when changing to the specified conditions.
local WeatherChanges =
{
[wSunny] = "Changed the weather to sunny.",
[wRain] = "Changed the weather to rainy.",
[wStorm] = "Changed the weather to stormy.",
}
function HandleWeatherCommand(Split, Player)
local Response
-- Parse the command into components...
local Weather = WeatherNames[Split[2]]
local TPS = 20
local TicksToChange = (tonumber(Split[3]) or 0) * TPS
local WorldName = Split[4]
if not tonumber(Split[3]) then
WorldName = Split[3]
end
local World = GetWorld(WorldName, Player) -- Function is in functions.lua.
if not Weather then
Response = SendMessage(Player, cChatColor.LightGray .. "Usage: " .. Split[1] .. " <sunny | rainy | stormy> [ticks] [world]")
elseif not World then
Response = SendMessageFailure(Player, "Couldn't find that world (" .. WorldName .. "), did you use Caps?")
else
World:SetWeather(Weather)
if TicksToChange ~= 0 then
World:SetTicksUntilWeatherChange(TicksToChange)
end
Response = SendMessageSuccess(Player, WeatherChanges[Weather])
end
return true, Response
end