2017-02-20 20:05:26 +02:00
|
|
|
-- turn off lightning mod 'auto mode'
|
|
|
|
lightning.auto = false
|
|
|
|
|
|
|
|
thunder = {
|
|
|
|
next_strike = 0,
|
|
|
|
min_delay = 3,
|
|
|
|
max_delay = 12,
|
2017-11-12 02:36:37 +02:00
|
|
|
init_done = false,
|
2017-02-20 20:05:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
if weather.state ~= "thunder" then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2017-11-12 02:52:07 +02:00
|
|
|
rain.set_particles_mode("thunder")
|
2017-02-20 20:05:26 +02:00
|
|
|
rain.make_weather()
|
2017-11-12 02:36:37 +02:00
|
|
|
|
|
|
|
if thunder.init_done == false then
|
|
|
|
skycolor.add_layer(
|
|
|
|
"weather-pack-thunder-sky",
|
|
|
|
{{r=0, g=0, b=0},
|
|
|
|
{r=40, g=40, b=40},
|
|
|
|
{r=85, g=86, b=86},
|
|
|
|
{r=40, g=40, b=40},
|
|
|
|
{r=0, g=0, b=0}})
|
|
|
|
skycolor.active = true
|
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
|
|
|
player:set_clouds({color="#3D3D3FE8"})
|
|
|
|
end
|
|
|
|
thunder.init_done = true
|
|
|
|
end
|
2017-02-20 20:05:26 +02:00
|
|
|
|
2017-11-11 18:18:53 +02:00
|
|
|
if (thunder.next_strike <= minetest.get_gametime()) then
|
2017-02-20 20:05:26 +02:00
|
|
|
lightning.strike()
|
|
|
|
local delay = math.random(thunder.min_delay, thunder.max_delay)
|
2017-11-11 18:18:53 +02:00
|
|
|
thunder.next_strike = minetest.get_gametime() + delay
|
2017-02-20 20:05:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
thunder.clear = function()
|
|
|
|
rain.clear()
|
2017-11-12 02:36:37 +02:00
|
|
|
skycolor.remove_layer("weather-pack-thunder-sky")
|
|
|
|
skycolor.remove_layer("lightning")
|
|
|
|
thunder.init_done = false
|
2017-02-20 20:05:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- register thunderstorm weather
|
|
|
|
if weather.reg_weathers.thunder == nil then
|
|
|
|
weather.reg_weathers.thunder = {
|
|
|
|
clear = thunder.clear,
|
2017-11-12 06:02:20 +02:00
|
|
|
-- 10min - 20min
|
2017-11-12 06:27:18 +02:00
|
|
|
min_duration = 600,
|
|
|
|
max_duration = 1200,
|
2017-11-12 07:57:11 +02:00
|
|
|
transitions = {
|
|
|
|
[100] = "rain",
|
|
|
|
}
|
2017-02-20 20:05:26 +02:00
|
|
|
}
|
2017-11-11 18:18:53 +02:00
|
|
|
end
|