2021-03-16 16:43:32 +00:00
|
|
|
local get_connected_players = minetest.get_connected_players
|
|
|
|
|
2017-11-21 00:35:31 +00:00
|
|
|
mcl_weather.snow = {}
|
2017-02-20 18:05:26 +00:00
|
|
|
|
2017-11-21 00:35:31 +00:00
|
|
|
mcl_weather.snow.particles_count = 15
|
|
|
|
mcl_weather.snow.init_done = false
|
2017-02-20 18:05:26 +00:00
|
|
|
|
2022-01-30 19:09:58 +00:00
|
|
|
local psdef= {
|
|
|
|
amount = 99,
|
|
|
|
time = 0, --stay on til we turn it off
|
|
|
|
minpos = vector.new(-15,-5,-15),
|
|
|
|
maxpos =vector.new(15,10,15),
|
|
|
|
minvel = vector.new(0,-1,0),
|
|
|
|
maxvel = vector.new(0,-4,0),
|
|
|
|
minacc = vector.new(0,-1,0),
|
|
|
|
maxacc = vector.new(0,-4,0),
|
|
|
|
minexptime = 1,
|
|
|
|
maxexptime = 1,
|
|
|
|
minsize = 0.5,
|
|
|
|
maxsize = 5,
|
|
|
|
collisiondetection = true,
|
|
|
|
collision_removal = true,
|
|
|
|
object_collision = true,
|
|
|
|
vertical = true,
|
|
|
|
glow = 1
|
|
|
|
}
|
|
|
|
|
2021-05-27 22:34:58 +00:00
|
|
|
function mcl_weather.snow.set_sky_box()
|
2021-05-23 12:44:50 +00:00
|
|
|
mcl_weather.skycolor.add_layer(
|
|
|
|
"weather-pack-snow-sky",
|
|
|
|
{{r=0, g=0, b=0},
|
|
|
|
{r=85, g=86, b=86},
|
|
|
|
{r=135, g=135, b=135},
|
|
|
|
{r=85, g=86, b=86},
|
|
|
|
{r=0, g=0, b=0}})
|
|
|
|
mcl_weather.skycolor.active = true
|
|
|
|
for _, player in pairs(get_connected_players()) do
|
|
|
|
player:set_clouds({color="#ADADADE8"})
|
|
|
|
end
|
|
|
|
mcl_weather.skycolor.active = true
|
2017-02-20 18:05:26 +00:00
|
|
|
end
|
|
|
|
|
2021-05-23 12:44:50 +00:00
|
|
|
function mcl_weather.snow.clear()
|
|
|
|
mcl_weather.skycolor.remove_layer("weather-pack-snow-sky")
|
|
|
|
mcl_weather.snow.init_done = false
|
2022-01-30 23:35:26 +00:00
|
|
|
mcl_weather.remove_all_spawners()
|
2017-02-20 18:05:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Simple random texture getter
|
2021-05-23 12:44:50 +00:00
|
|
|
function mcl_weather.snow.get_texture()
|
|
|
|
return "weather_pack_snow_snowflake"..math.random(1,2)..".png"
|
2017-02-20 18:05:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local timer = 0
|
|
|
|
minetest.register_globalstep(function(dtime)
|
2021-05-23 12:44:50 +00:00
|
|
|
if mcl_weather.state ~= "snow" then
|
|
|
|
return false
|
|
|
|
end
|
2017-02-20 18:05:26 +00:00
|
|
|
|
2021-05-23 12:44:50 +00:00
|
|
|
timer = timer + dtime;
|
|
|
|
if timer >= 0.5 then
|
|
|
|
timer = 0
|
|
|
|
else
|
|
|
|
return
|
|
|
|
end
|
2017-02-20 18:05:26 +00:00
|
|
|
|
2021-05-23 12:44:50 +00:00
|
|
|
if mcl_weather.snow.init_done == false then
|
|
|
|
mcl_weather.snow.set_sky_box()
|
|
|
|
mcl_weather.snow.init_done = true
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, player in pairs(get_connected_players()) do
|
2022-01-30 23:35:26 +00:00
|
|
|
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos()) or not mcl_weather.is_outdoor(player:get_pos())) then
|
2022-01-30 19:09:58 +00:00
|
|
|
mcl_weather.remove_spawners_player(player)
|
2021-05-23 12:44:50 +00:00
|
|
|
return false
|
|
|
|
end
|
2022-01-30 19:09:58 +00:00
|
|
|
for i=1,2 do
|
|
|
|
psdef.texture="weather_pack_snow_snowflake"..i..".png"
|
|
|
|
mcl_weather.add_spawner_player(player,"snow"..i,psdef)
|
|
|
|
end
|
2021-05-23 12:44:50 +00:00
|
|
|
end
|
2017-02-20 18:05:26 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
-- register snow weather
|
2017-11-21 00:35:31 +00:00
|
|
|
if mcl_weather.reg_weathers.snow == nil then
|
2021-01-27 22:02:52 +00:00
|
|
|
mcl_weather.reg_weathers.snow = {
|
|
|
|
clear = mcl_weather.snow.clear,
|
|
|
|
light_factor = 0.6,
|
|
|
|
-- 10min - 20min
|
|
|
|
min_duration = 600,
|
|
|
|
max_duration = 1200,
|
|
|
|
transitions = {
|
|
|
|
[65] = "none",
|
|
|
|
[80] = "rain",
|
|
|
|
[100] = "thunder",
|
|
|
|
}
|
|
|
|
}
|
2017-02-20 18:05:26 +00:00
|
|
|
end
|