2013-03-24 14:40:18 +01:00
|
|
|
minetest.register_privilege("weather", {
|
|
|
|
description = "Change the weather",
|
|
|
|
give_to_singleplayer = false
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Set weather
|
|
|
|
minetest.register_chatcommand("setweather", {
|
|
|
|
params = "<weather>",
|
2018-04-29 18:50:51 +02:00
|
|
|
description = "Set weather to a registered type of downfall\
|
2018-05-17 13:44:33 +02:00
|
|
|
show all types when no parameters are given", -- full description
|
2013-03-24 14:40:18 +01:00
|
|
|
privs = {weather = true},
|
2018-04-29 17:22:05 +02:00
|
|
|
func = function(name, param)
|
2018-05-17 13:44:33 +02:00
|
|
|
if param == nil or param == "" or param == "?" then
|
2018-04-29 17:22:05 +02:00
|
|
|
local types="none"
|
|
|
|
for i,_ in pairs(weather_mod.registered_downfalls) do
|
|
|
|
types=types..", "..i
|
|
|
|
end
|
|
|
|
minetest.chat_send_player(name, "avalible weather types: "..types)
|
|
|
|
else
|
2018-06-30 17:23:53 +02:00
|
|
|
if weather_mod.registered_downfalls[param] == nil and not param == "none" then
|
2018-05-17 17:21:41 +02:00
|
|
|
minetest.chat_send_player(name, "This type of weather is not registered.\n"..
|
|
|
|
"To list all types of weather run the command without parameters.")
|
2018-05-17 13:44:33 +02:00
|
|
|
else
|
|
|
|
weather.type = param
|
|
|
|
weather_mod.handle_lightning()
|
2020-09-13 07:58:17 +02:00
|
|
|
weather_mod.handle_weather_change({type = param, reason = "command", player = name})
|
2018-05-17 13:44:33 +02:00
|
|
|
end
|
2018-04-29 17:22:05 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
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
|
|
|
|
minetest.chat_send_player(name, "please provide two comma seperated numbers")
|
|
|
|
return
|
|
|
|
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
|
|
|
|
weather.wind = vector.new(x,0,z)
|
2020-09-13 07:58:17 +02:00
|
|
|
weather_mod.handle_weather_change({wind = true, reason = "command", player = name})
|
2018-04-29 17:22:05 +02:00
|
|
|
else
|
|
|
|
minetest.chat_send_player(name, param.." are not two comma seperated numbers")
|
|
|
|
end
|
2013-03-24 14:40:18 +01:00
|
|
|
end
|
|
|
|
})
|