mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
[mcl_weather] fix warnings
This commit is contained in:
parent
21b7647731
commit
5f8d79b37a
5 changed files with 122 additions and 124 deletions
|
@ -249,7 +249,7 @@ if mcl_weather.allow_abm then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Wetten the soil
|
-- Wetten the soil
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -264,7 +264,7 @@ if mcl_weather.allow_abm then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if mcl_weather.reg_weathers.rain == nil then
|
if mcl_weather.reg_weathers.rain == nil then
|
||||||
|
|
|
@ -205,8 +205,8 @@ mcl_weather.skycolor = {
|
||||||
-- Returns first player sky color. I assume that all players are in same color layout.
|
-- Returns first player sky color. I assume that all players are in same color layout.
|
||||||
get_current_bg_color = function()
|
get_current_bg_color = function()
|
||||||
local players = mcl_weather.skycolor.utils.get_players(nil)
|
local players = mcl_weather.skycolor.utils.get_players(nil)
|
||||||
for _, player in ipairs(players) do
|
if players[1] then
|
||||||
return player:get_sky()
|
return players[1]:get_sky()
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,78 +7,78 @@ mcl_weather.snow.init_done = false
|
||||||
|
|
||||||
-- calculates coordinates and draw particles for snow weather
|
-- calculates coordinates and draw particles for snow weather
|
||||||
mcl_weather.snow.add_snow_particles = function(player)
|
mcl_weather.snow.add_snow_particles = function(player)
|
||||||
mcl_weather.rain.last_rp_count = 0
|
mcl_weather.rain.last_rp_count = 0
|
||||||
for i=mcl_weather.snow.particles_count, 1,-1 do
|
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)
|
local random_pos_x, _, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player)
|
||||||
random_pos_y = math.random() + math.random(player:get_pos().y - 1, player:get_pos().y + 7)
|
local random_pos_y = math.random() + math.random(player:get_pos().y - 1, player:get_pos().y + 7)
|
||||||
if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then
|
if minetest.get_node_light({x=random_pos_x, y=random_pos_y, z=random_pos_z}, 0.5) == 15 then
|
||||||
mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1
|
mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z},
|
pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z},
|
||||||
velocity = {x = math.random(-100,100)*0.001, y = math.random(-300,-100)*0.004, z = math.random(-100,100)*0.001},
|
velocity = {x = math.random(-100,100)*0.001, y = math.random(-300,-100)*0.004, z = math.random(-100,100)*0.001},
|
||||||
acceleration = {x = 0, y=0, z = 0},
|
acceleration = {x = 0, y=0, z = 0},
|
||||||
expirationtime = 8.0,
|
expirationtime = 8.0,
|
||||||
size = 1,
|
size = 1,
|
||||||
collisiondetection = true,
|
collisiondetection = true,
|
||||||
collision_removal = true,
|
collision_removal = true,
|
||||||
object_collision = false,
|
object_collision = false,
|
||||||
vertical = false,
|
vertical = false,
|
||||||
texture = mcl_weather.snow.get_texture(),
|
texture = mcl_weather.snow.get_texture(),
|
||||||
playername = player:get_player_name()
|
playername = player:get_player_name()
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_weather.snow.set_sky_box = function()
|
mcl_weather.snow.set_sky_box = function()
|
||||||
mcl_weather.skycolor.add_layer(
|
mcl_weather.skycolor.add_layer(
|
||||||
"weather-pack-snow-sky",
|
"weather-pack-snow-sky",
|
||||||
{{r=0, g=0, b=0},
|
{{r=0, g=0, b=0},
|
||||||
{r=85, g=86, b=86},
|
{r=85, g=86, b=86},
|
||||||
{r=135, g=135, b=135},
|
{r=135, g=135, b=135},
|
||||||
{r=85, g=86, b=86},
|
{r=85, g=86, b=86},
|
||||||
{r=0, g=0, b=0}})
|
{r=0, g=0, b=0}})
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
for _, player in pairs(get_connected_players()) do
|
for _, player in pairs(get_connected_players()) do
|
||||||
player:set_clouds({color="#ADADADE8"})
|
player:set_clouds({color="#ADADADE8"})
|
||||||
end
|
end
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_weather.snow.clear = function()
|
function mcl_weather.snow.clear()
|
||||||
mcl_weather.skycolor.remove_layer("weather-pack-snow-sky")
|
mcl_weather.skycolor.remove_layer("weather-pack-snow-sky")
|
||||||
mcl_weather.snow.init_done = false
|
mcl_weather.snow.init_done = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Simple random texture getter
|
-- Simple random texture getter
|
||||||
mcl_weather.snow.get_texture = function()
|
function mcl_weather.snow.get_texture()
|
||||||
return "weather_pack_snow_snowflake"..math.random(1,2)..".png"
|
return "weather_pack_snow_snowflake"..math.random(1,2)..".png"
|
||||||
end
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
if mcl_weather.state ~= "snow" then
|
if mcl_weather.state ~= "snow" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
timer = timer + dtime;
|
timer = timer + dtime;
|
||||||
if timer >= 0.5 then
|
if timer >= 0.5 then
|
||||||
timer = 0
|
timer = 0
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if mcl_weather.snow.init_done == false then
|
if mcl_weather.snow.init_done == false then
|
||||||
mcl_weather.snow.set_sky_box()
|
mcl_weather.snow.set_sky_box()
|
||||||
mcl_weather.snow.init_done = true
|
mcl_weather.snow.init_done = true
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, player in pairs(get_connected_players()) do
|
for _, player in pairs(get_connected_players()) do
|
||||||
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then
|
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
mcl_weather.snow.add_snow_particles(player)
|
mcl_weather.snow.add_snow_particles(player)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- register snow weather
|
-- register snow weather
|
||||||
|
|
|
@ -4,60 +4,58 @@ local get_connected_players = minetest.get_connected_players
|
||||||
lightning.auto = false
|
lightning.auto = false
|
||||||
|
|
||||||
mcl_weather.thunder = {
|
mcl_weather.thunder = {
|
||||||
next_strike = 0,
|
next_strike = 0,
|
||||||
min_delay = 3,
|
min_delay = 3,
|
||||||
max_delay = 12,
|
max_delay = 12,
|
||||||
init_done = false,
|
init_done = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
if mcl_weather.get_weather() ~= "thunder" then
|
if mcl_weather.get_weather() ~= "thunder" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_weather.rain.set_particles_mode("thunder")
|
mcl_weather.rain.set_particles_mode("thunder")
|
||||||
mcl_weather.rain.make_weather()
|
mcl_weather.rain.make_weather()
|
||||||
|
|
||||||
if mcl_weather.thunder.init_done == false then
|
|
||||||
mcl_weather.skycolor.add_layer(
|
|
||||||
"weather-pack-thunder-sky",
|
|
||||||
{{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 pairs(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
|
|
||||||
|
|
||||||
|
if mcl_weather.thunder.init_done == false then
|
||||||
|
mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", {
|
||||||
|
{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 pairs(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)
|
end)
|
||||||
|
|
||||||
mcl_weather.thunder.clear = function()
|
function mcl_weather.thunder.clear()
|
||||||
mcl_weather.rain.clear()
|
mcl_weather.rain.clear()
|
||||||
mcl_weather.skycolor.remove_layer("weather-pack-thunder-sky")
|
mcl_weather.skycolor.remove_layer("weather-pack-thunder-sky")
|
||||||
mcl_weather.skycolor.remove_layer("lightning")
|
mcl_weather.skycolor.remove_layer("lightning")
|
||||||
mcl_weather.thunder.init_done = false
|
mcl_weather.thunder.init_done = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- register thunderstorm weather
|
-- register thunderstorm weather
|
||||||
if mcl_weather.reg_weathers.thunder == nil then
|
if mcl_weather.reg_weathers.thunder == nil then
|
||||||
mcl_weather.reg_weathers.thunder = {
|
mcl_weather.reg_weathers.thunder = {
|
||||||
clear = mcl_weather.thunder.clear,
|
clear = mcl_weather.thunder.clear,
|
||||||
light_factor = 0.33333,
|
light_factor = 0.33333,
|
||||||
-- 10min - 20min
|
-- 10min - 20min
|
||||||
min_duration = 600,
|
min_duration = 600,
|
||||||
max_duration = 1200,
|
max_duration = 1200,
|
||||||
transitions = {
|
transitions = {
|
||||||
[100] = "rain",
|
[100] = "rain",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
local S = minetest.get_translator("mcl_weather")
|
local S = minetest.get_translator("mcl_weather")
|
||||||
|
|
||||||
|
local math = math
|
||||||
|
|
||||||
-- weather states, 'none' is default, other states depends from active mods
|
-- weather states, 'none' is default, other states depends from active mods
|
||||||
mcl_weather.state = "none"
|
mcl_weather.state = "none"
|
||||||
|
|
||||||
|
@ -96,9 +98,7 @@ mcl_weather.get_random_pos_by_player_look_dir = function(player)
|
||||||
local look_dir = player:get_look_dir()
|
local look_dir = player:get_look_dir()
|
||||||
local player_pos = player:get_pos()
|
local player_pos = player:get_pos()
|
||||||
|
|
||||||
local random_pos_x = 0
|
local random_pos_x, random_pos_y, random_pos_z
|
||||||
local random_pos_y = 0
|
|
||||||
local random_pos_z = 0
|
|
||||||
|
|
||||||
if look_dir.x > 0 then
|
if look_dir.x > 0 then
|
||||||
if look_dir.z > 0 then
|
if look_dir.z > 0 then
|
||||||
|
|
Loading…
Reference in a new issue