readd old chat commands and priv

This commit is contained in:
cora 2021-09-26 03:43:18 +02:00
parent dbbecc94d0
commit 2c372684ce
1 changed files with 64 additions and 16 deletions

View File

@ -245,23 +245,71 @@ minetest.register_on_leaveplayer(function(player)
cla_weather.stop_weather_player(player:get_player_name()) cla_weather.stop_weather_player(player:get_player_name())
end) end)
minetest.register_privilege("weather_manager", {
minetest.register_chatcommand("cw",{ description = S("Gives ability to control weather"),
func=function(name,param) give_to_singleplayer = false
mcl_weather.change(param,true)
end
}) })
minetest.register_chatcommand("sc",{
func=function(name,param) -- Weather command definition. Set
mcl_weather.skycolor.add_layer("weather",{{r=0, g=0, b=0}, minetest.register_chatcommand("weather", {
{r=85, g=86, b=98}, params = "(clear | rain | snow | thunder) [<duration>]",
{r=135, g=135, b=151}, description = S("Changes the weather to the specified parameter."),
{r=85, g=86, b=98}, privs = {weather_manager = true},
{r=0, g=0, b=0}}) func = function(name, param)
--def.skylayer) if (param == "") then
mcl_weather.skycolor.active = true return false, S("Error: No weather specified.")
mcl_weather.skycolor.update_sky_color() end
end
local new_weather, duration
local parse1, parse2 = string.match(param, "(%w+) ?(%d*)")
if parse1 then
if parse1 == "clear" then
new_weather = "none"
else
new_weather = parse1
end
else
return false, S("Error: Invalid parameters.")
end
if parse2 then
if type(tonumber(parse2)) == "number" then
duration = tonumber(parse2)
if duration < 1 then
return false, S("Error: Duration can't be less than 1 second.")
end
end
end
local def=mcl_weather.get_weatherdef(param)
if def then
mcl_weather.stop_weather(mcl_weather.get_weatherdef(mcl_weather.state))
if duration then
def.min_duration=duration
def.max_duration=duration
end
mcl_weather.start_weather(def)
return true
end
return false, S("Error: Invalid weather specified. Use “clear”, “rain”, “snow” or “thunder”.")
end
})
minetest.register_chatcommand("toggledownfall", {
params = "",
description = S("Toggles between clear weather and weather with downfall (randomly rain, thunderstorm or snow)"),
privs = {weather_manager = true},
func = function(name, param)
-- Currently rain/thunder/snow: Set weather to clear
if mcl_weather.state ~= "none" then
mcl_weather.change("none")
-- Currently clear: Set weather randomly to rain/thunder/snow
else
local new = { "rain", "thunder", "snow" }
local r = math.random(1, #new)
return mcl_weather.change(new[r],true)
end
end
}) })
mcl_weather.register_weather("none",{ mcl_weather.register_weather("none",{