mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-26 18:09:33 +01:00
Add error handling for invalid /weather syntax
This commit is contained in:
parent
e4938ae8d1
commit
7a64990ffa
1 changed files with 10 additions and 1 deletions
|
@ -137,12 +137,18 @@ minetest.register_chatcommand("weather", {
|
|||
description = "Changes the weather to the specified parameter.",
|
||||
privs = {weather_manager = true},
|
||||
func = function(name, param)
|
||||
if (param == "") then
|
||||
minetest.chat_send_player(name, "Error: No weather specified.")
|
||||
return
|
||||
end
|
||||
local success = false
|
||||
if (param == "clear") then
|
||||
if (weather.state ~= nil and weather.reg_weathers[weather.state] ~= nil) then
|
||||
weather.reg_weathers[weather.state].clear()
|
||||
weather.state = param
|
||||
end
|
||||
weather.state = "none"
|
||||
success = true
|
||||
return
|
||||
end
|
||||
|
||||
if (weather.reg_weathers ~= nil and weather.reg_weathers[param] ~= nil) then
|
||||
|
@ -150,6 +156,9 @@ minetest.register_chatcommand("weather", {
|
|||
weather.reg_weathers[weather.state].clear()
|
||||
end
|
||||
weather.state = param
|
||||
return
|
||||
else
|
||||
minetest.chat_send_player(name, "Error: Invalid weather specified. Use “clear”, “rain”, “snow” or “thunder”.")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue