fix thunder/lightning never stopping

This commit is contained in:
cora 2021-09-27 23:03:28 +02:00
parent e854be9f0f
commit 8f619ab5c3
1 changed files with 18 additions and 12 deletions

View File

@ -2,12 +2,20 @@ mcl_weather.thunder = {
min_delay = 3,
max_delay = 12
}
lightning.auto=false
local thunderactive=false
local function do_thunder(start)
if not start and mcl_weather.current ~= "thunder" then return end
if (start and not thunderactive) or mcl_weather.current == "thunder" then
local delay = math.random(mcl_weather.thunder.min_delay, mcl_weather.thunder.max_delay)
lightning.strike()
minetest.after(delay,do_thunder)
thunderactive=true
else
thunderactive=false
end
minetest.chat_send_all("thunder "..mcl_weather.current)
lightning.strike()
end
mcl_weather.register_weather("thunder",{
@ -90,15 +98,13 @@ mcl_weather.register_weather("thunder",{
start = function()
do_thunder(true)
end,
start_player = function(name) end,
clear = function()
mcl_weather.skycolor.remove_layer("lightning")
end,
at_pos = function(pos)
local biome=minetest.get_biome_data(pos)
if mcl_worlds.has_weather(pos) and biome.heat > 15 and biome.heat < 95 then
if not mcl_worlds.has_weather(pos) and biome.heat > 95 then
return true
end
end,
change_at_pos = "snow"
end
})