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