Update patches

This commit is contained in:
Till Affeldt
2024-09-26 22:10:09 +02:00
parent eaaacfd7cd
commit f864b8ea7c
5 changed files with 41 additions and 28 deletions

View File

@ -11,7 +11,8 @@ local default_intensity = tonumber(minetest.settings:get("enable_shadows_default
local intensity = tonumber(storage:get("intensity") or default_intensity)
minetest.register_on_joinplayer(function(player)
lighting_monoids.shadows:add_change(player, intensity, "enable_shadows:base_value")
local lighting = { shadows = { intensity = intensity } }
lighting_monoid:add_change(player, lighting, "enable_shadows:base_value")
end)
minetest.override_chatcommand("shadow_intensity", {

View File

@ -1,13 +1,30 @@
-- Hook into MTG weather mod for compatibility (requires PR #3020)
if weather ~= nil and weather.on_update ~= nil then
weather.on_update = function(player, overrides)
if overrides == nil then
return
local CYCLE = 8
local BASE_SHADOW = 0.33
-- weather API not supported, no patch possible
if weather == nil or weather.get == nil then
minetest.log("warning", "[Lighting_Monoid] 'weather' mod does not support patching via API. If you are playing Minetest Game, update to the latest version")
return
end
-- prevent mod from triggering lighting updates itself
local old_get = weather.get
weather.get = function(player)
local params = old_get(player)
params.lighting = nil
return params
end
local function do_update()
for _, player in ipairs(minetest.get_connected_players()) do
local params = old_get(player)
local lighting = params.lighting
if lighting ~= nil and lighting.shadows ~= nil and lighting.shadows.intensity ~= nil then
-- normalize in relation to default intensity
lighting.shadows.intensity = lighting.shadows.intensity / BASE_SHADOW
end
if overrides.shadows then
lighting_monoid:add_change(player, { shadows = overrides.shadows }, "weather:cloud_shadows")
end
overrides.lighting = nil
return overrides
lighting_monoid:add_change(player, lighting, "weather:lighting")
end
end
minetest.after(CYCLE, do_update)
end
minetest.after(0, do_update)