2017-02-20 18:05:26 +00:00
|
|
|
-- turn off lightning mod 'auto mode'
|
|
|
|
lightning.auto = false
|
|
|
|
|
|
|
|
thunder = {
|
|
|
|
next_strike = 0,
|
|
|
|
min_delay = 3,
|
|
|
|
max_delay = 12,
|
|
|
|
}
|
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
if weather.state ~= "thunder" then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
rain.make_weather()
|
|
|
|
|
2017-11-11 16:18:53 +00:00
|
|
|
if (thunder.next_strike <= minetest.get_gametime()) then
|
2017-02-20 18:05:26 +00:00
|
|
|
lightning.strike()
|
|
|
|
local delay = math.random(thunder.min_delay, thunder.max_delay)
|
2017-11-11 16:18:53 +00:00
|
|
|
thunder.next_strike = minetest.get_gametime() + delay
|
2017-02-20 18:05:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
thunder.clear = function()
|
|
|
|
rain.clear()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- register thunderstorm weather
|
|
|
|
if weather.reg_weathers.thunder == nil then
|
|
|
|
weather.reg_weathers.thunder = {
|
|
|
|
chance = 5,
|
|
|
|
clear = thunder.clear,
|
|
|
|
min_duration = 120,
|
|
|
|
max_duration = 600,
|
|
|
|
}
|
2017-11-11 16:18:53 +00:00
|
|
|
end
|