2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow = {}
|
2017-02-20 19:05:26 +01:00
|
|
|
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow.particles_count = 15
|
|
|
|
mcl_weather.snow.init_done = false
|
2017-02-20 19:05:26 +01:00
|
|
|
|
|
|
|
-- calculates coordinates and draw particles for snow weather
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow.add_snow_particles = function(player)
|
|
|
|
mcl_weather.rain.last_rp_count = 0
|
|
|
|
for i=mcl_weather.snow.particles_count, 1,-1 do
|
|
|
|
local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player)
|
2017-02-20 19:05:26 +01:00
|
|
|
random_pos_y = math.random() + math.random(player:getpos().y - 1, player:getpos().y + 7)
|
|
|
|
if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1
|
2017-02-20 19:05:26 +01:00
|
|
|
minetest.add_particle({
|
|
|
|
pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z},
|
|
|
|
velocity = {x = math.random(-1,-0.5), y = math.random(-2,-1), z = math.random(-1,-0.5)},
|
|
|
|
acceleration = {x = math.random(-1,-0.5), y=-0.5, z = math.random(-1,-0.5)},
|
|
|
|
expirationtime = 2.0,
|
|
|
|
size = math.random(0.5, 2),
|
|
|
|
collisiondetection = true,
|
|
|
|
collision_removal = true,
|
|
|
|
vertical = true,
|
2017-11-21 01:35:31 +01:00
|
|
|
texture = mcl_weather.snow.get_texture(),
|
2017-02-20 19:05:26 +01:00
|
|
|
playername = player:get_player_name()
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow.set_sky_box = function()
|
|
|
|
mcl_weather.skycolor.add_layer(
|
2017-02-20 19:05:26 +01:00
|
|
|
"weather-pack-snow-sky",
|
|
|
|
{{r=0, g=0, b=0},
|
|
|
|
{r=241, g=244, b=249},
|
|
|
|
{r=0, g=0, b=0}}
|
|
|
|
)
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.skycolor.active = true
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow.clear = function()
|
|
|
|
mcl_weather.skycolor.remove_layer("weather-pack-snow-sky")
|
|
|
|
mcl_weather.snow.init_done = false
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Simple random texture getter
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow.get_texture = function()
|
2017-02-20 19:05:26 +01:00
|
|
|
local texture_name
|
|
|
|
local random_number = math.random()
|
|
|
|
if random_number > 0.5 then
|
|
|
|
texture_name = "weather_pack_snow_snowflake1.png"
|
|
|
|
else
|
|
|
|
texture_name = "weather_pack_snow_snowflake2.png"
|
|
|
|
end
|
|
|
|
return texture_name;
|
|
|
|
end
|
|
|
|
|
|
|
|
local timer = 0
|
|
|
|
minetest.register_globalstep(function(dtime)
|
2017-11-21 01:35:31 +01:00
|
|
|
if mcl_weather.state ~= "snow" then
|
2017-02-20 19:05:26 +01:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
timer = timer + dtime;
|
|
|
|
if timer >= 0.5 then
|
|
|
|
timer = 0
|
|
|
|
else
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2017-11-21 01:35:31 +01:00
|
|
|
if mcl_weather.snow.init_done == false then
|
|
|
|
mcl_weather.snow.set_sky_box()
|
|
|
|
mcl_weather.snow.init_done = true
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
for _, player in ipairs(minetest.get_connected_players()) do
|
2017-11-21 01:35:31 +01:00
|
|
|
if (mcl_weather.is_underwater(player) or not mcl_util.has_weather(player:getpos())) then
|
2017-02-20 19:05:26 +01:00
|
|
|
return false
|
|
|
|
end
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow.add_snow_particles(player)
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- register snow weather
|
2017-11-21 01:35:31 +01:00
|
|
|
if mcl_weather.reg_weathers.snow == nil then
|
|
|
|
mcl_weather.reg_weathers.snow = {
|
|
|
|
clear = mcl_weather.snow.clear,
|
2017-11-22 01:41:23 +01:00
|
|
|
light_factor = 0.6,
|
2017-11-12 05:02:20 +01:00
|
|
|
-- 10min - 20min
|
2017-11-12 05:27:18 +01:00
|
|
|
min_duration = 600,
|
|
|
|
max_duration = 1200,
|
2017-11-12 06:57:11 +01:00
|
|
|
transitions = {
|
|
|
|
[65] = "none",
|
|
|
|
[80] = "rain",
|
|
|
|
[100] = "thunder",
|
|
|
|
}
|
2017-11-22 01:41:23 +01:00
|
|
|
}
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
|