Make everything dark for player when in weather (WIP)
This commit is contained in:
parent
562bd6cd5a
commit
b7880529a8
|
@ -39,6 +39,7 @@ rain.set_sky_box = function()
|
||||||
skycolor.active = true
|
skycolor.active = true
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
player:set_clouds({color="#5D5D5FE8"})
|
player:set_clouds({color="#5D5D5FE8"})
|
||||||
|
player:override_day_night_ratio(0.8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -145,6 +146,7 @@ rain.clear = function()
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
rain.remove_sound(player)
|
rain.remove_sound(player)
|
||||||
rain.remove_player(player)
|
rain.remove_player(player)
|
||||||
|
player:override_day_night_ratio(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ end
|
||||||
if weather.reg_weathers.rain == nil then
|
if weather.reg_weathers.rain == nil then
|
||||||
weather.reg_weathers.rain = {
|
weather.reg_weathers.rain = {
|
||||||
chance = 15,
|
chance = 15,
|
||||||
|
day_night_ratio = 0.8,
|
||||||
clear = rain.clear
|
clear = rain.clear
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -72,11 +72,34 @@ skycolor = {
|
||||||
end
|
end
|
||||||
|
|
||||||
players = skycolor.utils.get_players(players)
|
players = skycolor.utils.get_players(players)
|
||||||
|
|
||||||
|
-- Make everything darker for player
|
||||||
for _, player in ipairs(players) do
|
for _, player in ipairs(players) do
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
local _, dim = mcl_util.y_to_layer(pos.y)
|
local _, dim = mcl_util.y_to_layer(pos.y)
|
||||||
if dim == "overworld" then
|
if dim == "overworld" then
|
||||||
player:set_sky(color, "plain", nil, true)
|
player:set_sky(color, "plain", nil, true)
|
||||||
|
|
||||||
|
local dnn = weather.get_current_day_night_ratio()
|
||||||
|
if dnn then
|
||||||
|
local w = minetest.get_timeofday()
|
||||||
|
if w > 0.5 then
|
||||||
|
w = 2*(1 - w)
|
||||||
|
else
|
||||||
|
w = 1 - (1 - 2*w)
|
||||||
|
end
|
||||||
|
if w > dnn then
|
||||||
|
-- FIXME: This color will cause a sharp brightness change.
|
||||||
|
-- The correct ratio value needs to be calculated.
|
||||||
|
player:override_day_night_ratio(dnn)
|
||||||
|
else
|
||||||
|
player:override_day_night_ratio(nil)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
player:override_day_night_ratio(nil)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
player:override_day_night_ratio(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -84,6 +84,7 @@ end)
|
||||||
if weather.reg_weathers.snow == nil then
|
if weather.reg_weathers.snow == nil then
|
||||||
weather.reg_weathers.snow = {
|
weather.reg_weathers.snow = {
|
||||||
chance = 10,
|
chance = 10,
|
||||||
|
day_night_ratio = 0.8,
|
||||||
clear = snow.clear
|
clear = snow.clear
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,6 +27,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
skycolor.active = true
|
skycolor.active = true
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
player:set_clouds({color="#3D3D3FE8"})
|
player:set_clouds({color="#3D3D3FE8"})
|
||||||
|
|
||||||
end
|
end
|
||||||
thunder.init_done = true
|
thunder.init_done = true
|
||||||
end
|
end
|
||||||
|
@ -43,6 +44,9 @@ thunder.clear = function()
|
||||||
rain.clear()
|
rain.clear()
|
||||||
skycolor.remove_layer("weather-pack-thunder-sky")
|
skycolor.remove_layer("weather-pack-thunder-sky")
|
||||||
skycolor.remove_layer("lightning")
|
skycolor.remove_layer("lightning")
|
||||||
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
|
player:override_day_night_ratio(nil)
|
||||||
|
end
|
||||||
thunder.init_done = false
|
thunder.init_done = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,6 +54,7 @@ end
|
||||||
if weather.reg_weathers.thunder == nil then
|
if weather.reg_weathers.thunder == nil then
|
||||||
weather.reg_weathers.thunder = {
|
weather.reg_weathers.thunder = {
|
||||||
chance = 5,
|
chance = 5,
|
||||||
|
day_night_ratio = 0.33333,
|
||||||
clear = thunder.clear,
|
clear = thunder.clear,
|
||||||
min_duration = 120,
|
min_duration = 120,
|
||||||
max_duration = 600,
|
max_duration = 600,
|
||||||
|
|
|
@ -38,6 +38,14 @@ weather.get_rand_end_time = function(min_duration, max_duration)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
weather.get_current_day_night_ratio = function()
|
||||||
|
if weather.state == "none" then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
return weather.reg_weathers[weather.state].day_night_ratio
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns true if pos is outdoor.
|
-- Returns true if pos is outdoor.
|
||||||
-- Outdoor is defined as any node in the Overworld under open sky.
|
-- Outdoor is defined as any node in the Overworld under open sky.
|
||||||
-- FIXME: Nodes below glass also count as “outdoor”, this should not be the case.
|
-- FIXME: Nodes below glass also count as “outdoor”, this should not be the case.
|
||||||
|
|
Loading…
Reference in New Issue