From 710a1d717bb36cabfb82ee51b404a3ab915772cb Mon Sep 17 00:00:00 2001 From: Till Affeldt Date: Wed, 22 Feb 2023 05:21:52 +0100 Subject: [PATCH] Enable shadow registration, improve indoor check --- lib/influences.lua | 8 +++++--- lib/skybox_merger.lua | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/influences.lua b/lib/influences.lua index e5d9463..e28bf8b 100644 --- a/lib/influences.lua +++ b/lib/influences.lua @@ -55,13 +55,15 @@ end) climate_api.register_influence("daylight", function(pos) pos = vector.add(pos, {x = 0, y = 1, z = 0}) - return minetest.get_node_light(pos, 0.5) or 0 + return minetest.get_natural_light(pos, 0.5) or 0 end) climate_api.register_influence("indoors", function(pos) pos = vector.add(pos, {x = 0, y = 1, z = 0}) - local daylight = minetest.get_node_light(pos, 0.5) or 0 - if daylight < 15 then return true end + local daylight = minetest.get_natural_light(pos, 0.5) or 0 + -- max light is 15 but allow adjacent nodes to still be outdoors + -- to reduce effect switching on and off when walking underneath single nodes + if daylight < 14 then return true end for i = 1, climate_mod.settings.ceiling_checks do local lpos = vector.add(pos, {x = 0, y = i, z = 0}) diff --git a/lib/skybox_merger.lua b/lib/skybox_merger.lua index 69a85b1..3876bcf 100644 --- a/lib/skybox_merger.lua +++ b/lib/skybox_merger.lua @@ -42,6 +42,10 @@ local default_sky = { count = 1000, star_color = "#ebebff69", scale = 1 + }, + light_data = { + shadow_intensity = 0.33, + saturation = 1 } } @@ -70,6 +74,12 @@ local function set_skybox(playername, sky) player:set_moon(sky.moon_data) player:set_sun(sky.sun_data) player:set_stars(sky.star_data) + if player.set_lighting then + player:set_lighting({ + shadows = { intensity = sky.light_data.shadow_intensity }, + saturation = sky.light_data.saturation + }) + end end function skybox.update(playername)