add thunder to new weather

This commit is contained in:
cora 2021-09-26 03:07:09 +02:00
parent a0fc6f682d
commit 01ddbe06bc
1 changed files with 89 additions and 53 deletions

View File

@ -1,61 +1,97 @@
-- turn off lightning mod 'auto mode'
lightning.auto = false
mcl_weather.thunder = {
next_strike = 0,
min_delay = 3,
max_delay = 12,
init_done = false,
max_delay = 12
}
minetest.register_globalstep(function(dtime)
if mcl_weather.get_weather() ~= "thunder" then
return false
end
mcl_weather.rain.set_particles_mode("thunder")
mcl_weather.rain.make_weather()
local function do_thunder(start)
if not start and mcl_weather.current ~= "thunder" then return end
local delay = math.random(mcl_weather.thunder.min_delay, mcl_weather.thunder.max_delay)
lightning.strike()
minetest.after(delay,do_thunder)
end
if mcl_weather.thunder.init_done == false then
mcl_weather.skycolor.add_layer(
"weather-pack-thunder-sky",
{{r=0, g=0, b=0},
mcl_weather.register_weather("thunder",{
light_factor = 0.33,
cloudcolor= "#3D3D3FE8" ,
sound = "weather_rain",
-- 10min - 20min
min_duration = 600,
max_duration = 1200,
transitions = {
[100] = "rain"
},
skylayer= {{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}})
mcl_weather.skycolor.active = true
for _, player in ipairs(minetest.get_connected_players()) do
player:set_clouds({color="#3D3D3FE8"})
end
mcl_weather.thunder.init_done = true
end
if (mcl_weather.thunder.next_strike <= minetest.get_gametime()) then
lightning.strike()
local delay = math.random(mcl_weather.thunder.min_delay, mcl_weather.thunder.max_delay)
mcl_weather.thunder.next_strike = minetest.get_gametime() + delay
end
end)
mcl_weather.thunder.clear = function()
mcl_weather.rain.clear()
mcl_weather.skycolor.remove_layer("weather-pack-thunder-sky")
mcl_weather.skycolor.remove_layer("lightning")
mcl_weather.thunder.init_done = false
end
-- register thunderstorm weather
if mcl_weather.reg_weathers.thunder == nil then
mcl_weather.reg_weathers.thunder = {
clear = mcl_weather.thunder.clear,
light_factor = 0.33333,
-- 10min - 20min
min_duration = 600,
max_duration = 1200,
transitions = {
[100] = "rain",
}
}
end
{r=0, g=0, b=0}},
particlespawners = {
{
amount = 1200,
time = 0,
minpos = vector.new(-15,5,-15),
maxpos =vector.new(15,10,15),
minvel = vector.new(0,-8,0),
maxvel = vector.new(0,-12,0),
minacc = vector.new(0,-20,0),
maxacc = vector.new(0,-30,0),
minexptime = 1,
maxexptime = 1,
minsize = 0.5,
maxsize = 5,
collisiondetection = true,
collision_removal = true,
object_collision = true,
vertical = true,
glow = 1,
texture="weather_pack_rain_raindrop_1.png"
},
{
amount = 800,
time = 0,
minpos = vector.new(-15,5,-15),
maxpos =vector.new(15,15,15),
minvel = vector.new(0,-8,0),
maxvel = vector.new(0,-12,0),
minacc = vector.new(0,-20,0),
maxacc = vector.new(0,-40,0),
minexptime = 1,
maxexptime = 1,
minsize = 0.5,
maxsize = 5,
collisiondetection = true,
collision_removal = true,
object_collision = true,
vertical = true,
glow = 1,
texture="weather_pack_rain_raindrop_2.png"
},
{
amount = 350,
time = 0,
minpos = vector.new(-5,0,-5),
maxpos = vector.new(5,0.8,5),
minvel = vector.new(-4, 5,-4),
maxvel = vector.new(4,10,4),
minacc = vector.new(0,10,0),
maxacc = vector.new(0,25,0),
minexptime = 0.01,
maxexptime = 0.04,
minsize = 0.5,
maxsize = 3,
collisiondetection = true,
collision_removal = true,
object_collision = true,
vertical = true,
texture = "weather_pack_rain_raindrop_2.png",
glow = 0
}
},
start = function()
do_thunder(true)
end,
start_player = function(name) end,
clear = function()
mcl_weather.skycolor.remove_layer("lightning")
end
})