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())
end)
minetest.register_chatcommand("cw",{
func=function(name,param)
mcl_weather.change(param,true)
end
minetest.register_privilege("weather_manager", {
description = S("Gives ability to control weather"),
give_to_singleplayer = false
})
minetest.register_chatcommand("sc",{
func=function(name,param)
mcl_weather.skycolor.add_layer("weather",{{r=0, g=0, b=0},
{r=85, g=86, b=98},
{r=135, g=135, b=151},
{r=85, g=86, b=98},
{r=0, g=0, b=0}})
--def.skylayer)
mcl_weather.skycolor.active = true
mcl_weather.skycolor.update_sky_color()
end
-- Weather command definition. Set
minetest.register_chatcommand("weather", {
params = "(clear | rain | snow | thunder) [<duration>]",
description = S("Changes the weather to the specified parameter."),
privs = {weather_manager = true},
func = function(name, param)
if (param == "") then
return false, S("Error: No weather specified.")
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",{