2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow = {}
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.snow.particlespawners = {}
|
2017-02-20 19:05:26 +01:00
|
|
|
|
2021-09-25 03:05:18 +02:00
|
|
|
local psdef= {
|
|
|
|
amount = 30,
|
|
|
|
time = 0,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
local function check_player(player)
|
|
|
|
if mcl_weather.state ~= "snow" then return false end
|
|
|
|
local name=player:get_player_name(name)
|
|
|
|
if mcl_worlds.has_weather(player:get_pos()) and not mcl_weather.snow.particlespawners[name] then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
mcl_weather.snow.add_particlespawners = function(player)
|
|
|
|
if not check_player(player) then
|
|
|
|
mcl_weather.snow.delete_particlespawners(player)
|
|
|
|
return
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
2021-09-25 03:05:18 +02:00
|
|
|
local name=player:get_player_name(name)
|
|
|
|
mcl_weather.snow.particlespawners[name]={}
|
|
|
|
psdef.playername = name
|
|
|
|
psdef.attached = player
|
|
|
|
for i=1,2 do
|
|
|
|
psdef.texture="weather_pack_snow_snowflake"..i..".png"
|
|
|
|
mcl_weather.snow.particlespawners[name][i]=minetest.add_particlespawner(psdef)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
mcl_weather.snow.delete_particlespawners = function(player)
|
|
|
|
local name=player:get_player_name(name)
|
|
|
|
if mcl_weather.snow.particlespawners[name] then
|
|
|
|
for i=1,2 do
|
|
|
|
minetest.delete_particlespawner(mcl_weather.snow.particlespawners[name][i])
|
|
|
|
end
|
|
|
|
mcl_weather.snow.particlespawners[name]=nil
|
|
|
|
end
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.snow.set_sky_box = function()
|
|
|
|
mcl_weather.skycolor.add_layer(
|
2017-12-01 16:02:29 +01:00
|
|
|
"weather-pack-snow-sky",
|
2017-02-20 19:05:26 +01:00
|
|
|
{{r=0, g=0, b=0},
|
2017-11-22 02:59:09 +01:00
|
|
|
{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
|
2021-02-18 16:25:30 +01:00
|
|
|
for _, player in ipairs(minetest.get_connected_players()) do
|
2021-09-25 03:05:18 +02:00
|
|
|
|
2017-11-22 02:59:09 +01:00
|
|
|
end
|
2017-11-21 01:35:31 +01:00
|
|
|
mcl_weather.skycolor.active = true
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.snow.start_player = function(player)
|
|
|
|
if check_player(player) then
|
|
|
|
mcl_weather.snow.add_particlespawners(player)
|
|
|
|
player:set_clouds({color="#ADADADE8"})
|
|
|
|
end
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
|
|
|
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.snow.clear_player = function(player)
|
|
|
|
mcl_weather.snow.delete_particlespawners(player)
|
|
|
|
end
|
2017-02-20 19:05:26 +01:00
|
|
|
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.snow.start = function()
|
|
|
|
for _, player in ipairs(minetest.get_connected_players()) do
|
|
|
|
mcl_weather.snow.start_player(player)
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.snow.set_sky_box()
|
|
|
|
mcl_weather.snow.init_done = true
|
|
|
|
end
|
2017-02-20 19:05:26 +01:00
|
|
|
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.snow.clear = function()
|
2017-02-20 19:05:26 +01:00
|
|
|
for _, player in ipairs(minetest.get_connected_players()) do
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.snow.clear_player(player)
|
2017-02-20 19:05:26 +01:00
|
|
|
end
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_weather.skycolor.remove_layer("weather-pack-snow-sky")
|
|
|
|
mcl_weather.snow.init_done = false
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
if mcl_weather.state ~= "snow" then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
if mcl_weather.rain.init_done == false then
|
|
|
|
mcl_weather.snow.start()
|
|
|
|
mcl_weather.rain.set_sky_box()
|
|
|
|
mcl_weather.rain.set_particles_mode(mcl_weather.mode)
|
|
|
|
elseif mcl_weather.state ~= "snow" then
|
|
|
|
mcl_weather.snow.clear()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
mcl_weather.snow.start_player(player)
|
|
|
|
end)
|
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
mcl_weather.snow.clear_player(player)
|
2017-02-20 19:05:26 +01:00
|
|
|
end)
|
|
|
|
|
2021-09-25 03:05:18 +02:00
|
|
|
mcl_worlds.register_on_dimension_change(function(player, dimension)
|
|
|
|
if dimension == "overworld" then
|
|
|
|
mcl_weather.snow.add_particlespawners(player)
|
|
|
|
else
|
|
|
|
mcl_weather.snow.delete_particlespawners(player)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-20 19:05:26 +01:00
|
|
|
-- register snow weather
|
2017-11-21 01:35:31 +01:00
|
|
|
if mcl_weather.reg_weathers.snow == nil then
|
2021-01-27 23:02:52 +01: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 19:05:26 +01:00
|
|
|
end
|