Fix for light night rain and dark day rain issue

This commit is contained in:
ancientmarinerdev 2023-03-27 03:11:33 +01:00 committed by Gitea
parent ce1393af0c
commit 2426570871

View file

@ -211,17 +211,39 @@ mcl_weather.skycolor = {
player:set_moon({visible = false}) player:set_moon({visible = false})
player:set_stars({visible = false}) player:set_stars({visible = false})
local lf = mcl_weather.get_current_light_factor() local light_factor = mcl_weather.get_current_light_factor()
if mcl_weather.skycolor.current_layer_name() == "lightning" then if mcl_weather.skycolor.current_layer_name() == "lightning" then
mcl_weather.skycolor.override_day_night_ratio(player, 1) mcl_weather.skycolor.override_day_night_ratio(player, 1)
elseif lf then elseif light_factor then
local w = minetest.get_timeofday() local time = minetest.get_timeofday()
local light = (w * (lf*2)) -- 0.5 = 1
if light > 1 then -- 0 = 0
light = 1 - (light - 1) -- 0.99 = 0
-- greater than 0.5, is
-- less than 0.5 = time / 0.5
-- 0.6 = 0.8
-- 0.9 = 0.2
-- 0.6 = 0.4
-- 0.9 = 0.1
-- 2 * (1 - time)
local light_multiplier = time * 2
if time > 0.5 then
light_multiplier = 2 * (1 - time)
else
light_multiplier = time / 0.5
end end
light = (light * lf) + 0.15 local minimum_light_level = 0.10
mcl_weather.skycolor.override_day_night_ratio(player, light)
minetest.log("New light_multiplier: " .. tostring(light_multiplier))
local new_light = (light_factor * (light_multiplier * (1-minimum_light_level))) + minimum_light_level
minetest.log("new_light: " .. tostring(new_light))
mcl_weather.skycolor.override_day_night_ratio(player, new_light)
else else
mcl_weather.skycolor.override_day_night_ratio(player, nil) mcl_weather.skycolor.override_day_night_ratio(player, nil)
end end