2013-03-24 14:40:18 +01:00
|
|
|
minetest.register_privilege("weather", {
|
|
|
|
description = "Change the weather",
|
|
|
|
give_to_singleplayer = false
|
|
|
|
})
|
|
|
|
|
2020-04-15 17:21:53 +02:00
|
|
|
local function list_types()
|
|
|
|
local types="none"
|
|
|
|
for i,_ in pairs(weather.registered_downfalls) do
|
|
|
|
types=types..", "..i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-24 14:40:18 +01:00
|
|
|
-- Set weather
|
|
|
|
minetest.register_chatcommand("setweather", {
|
2020-04-15 17:21:53 +02:00
|
|
|
params = "<weather>",
|
|
|
|
description = "Set weather to a registered type of downfall\
|
|
|
|
show all types when no parameters are given", -- full description
|
|
|
|
privs = {weather = true},
|
|
|
|
func = function(name, param)
|
|
|
|
if param == nil or param == "" or param == "?" then
|
|
|
|
return false, "registered weather types: "..list_types()
|
|
|
|
end
|
|
|
|
local w = weather.registered_downfalls[param]
|
|
|
|
if (not w) and param ~= "none" then
|
|
|
|
return false, "This type of weather is not registered.\n"..
|
|
|
|
"registered types: "..list_types()
|
|
|
|
end
|
|
|
|
if w.disabled then
|
|
|
|
minetest.chat_send_player(name,param.." is disabled.")
|
|
|
|
end
|
|
|
|
weather.set_weather(name,param)
|
|
|
|
--weather_mod.handle_lightning()
|
|
|
|
return true
|
|
|
|
end
|
2018-04-29 17:22:05 +02:00
|
|
|
})
|
|
|
|
|
2019-05-25 11:58:52 +02:00
|
|
|
-- Set wind
|
2018-04-29 17:22:05 +02:00
|
|
|
minetest.register_chatcommand("setwind", {
|
2019-05-25 11:58:52 +02:00
|
|
|
params = "<wind>",
|
2018-04-29 17:22:05 +02:00
|
|
|
description = "Set windspeed to the given x,z direction", -- full description
|
|
|
|
privs = {weather = true},
|
|
|
|
func = function(name, param)
|
|
|
|
if param==nil or param=="" then
|
2020-04-15 17:21:53 +02:00
|
|
|
return false,"please provide two comma seperated numbers"
|
2018-04-29 17:22:05 +02:00
|
|
|
end
|
|
|
|
local x,z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)$")
|
|
|
|
x=tonumber(x)
|
|
|
|
z=tonumber(z)
|
|
|
|
if (not x) or (not z) then
|
|
|
|
x, z = string.match(param, "^%( *([%d.-]+)[, ] *([%d.-]+) *%)$")
|
|
|
|
end
|
|
|
|
if x and z then
|
2020-04-15 17:21:53 +02:00
|
|
|
weather.set_wind(x,z)
|
|
|
|
return true
|
2018-04-29 17:22:05 +02:00
|
|
|
else
|
2020-04-15 17:21:53 +02:00
|
|
|
return false,param.." are not two comma seperated numbers"
|
2018-04-29 17:22:05 +02:00
|
|
|
end
|
2013-03-24 14:40:18 +01:00
|
|
|
end
|
|
|
|
})
|