mirror of
https://github.com/t-affeldt/lighting_monoids.git
synced 2025-07-07 02:50:22 +02:00
Update patches
This commit is contained in:
@ -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", {
|
||||
|
@ -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)
|
Reference in New Issue
Block a user