From cf9778abb342c54a1e36b5262553f6ea5db298ad Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Wed, 24 Apr 2024 13:51:20 -0400 Subject: [PATCH] mods weather: Fix error caused by missing biomes * backported from https://github.com/minetest/minetest_game/pull/2822/commits/3425f970099e72019b4f47a0847673437e03c0f6 --- mods/weather/init.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mods/weather/init.lua b/mods/weather/init.lua index c0d1098..add1d92 100644 --- a/mods/weather/init.lua +++ b/mods/weather/init.lua @@ -69,6 +69,7 @@ local function rangelim(value, lower, upper) return math.min(math.max(value, lower), upper) end +local is_older = minetest.has_feature("no_chat_message_prediction") local os_time_0 = os.time() local t_offset = math.random(0, 300000) @@ -88,14 +89,16 @@ local function update_clouds() local n_speedz = nobj_speedz:get_2d({x = time, y = 0}) for _, player in ipairs(minetest.get_connected_players()) do - local humid = minetest.get_humidity(player:get_pos()) - player:set_clouds({ - density = rangelim(humid / 100, 0.25, 1.0) * n_density, - thickness = math.max(math.floor( - rangelim(32 * humid / 100, 8, 32) * n_thickness - ), 1), - speed = {x = n_speedx * 4, z = n_speedz * 4}, - }) + local humid = minetest.get_humidity(player:get_pos()) or 50 + if is_older then + player:set_clouds({ + density = rangelim(humid / 100, 0.25, 1.0) * n_density, + thickness = math.max(math.floor( + rangelim(32 * humid / 100, 8, 32) * n_thickness + ), 1), + speed = {x = n_speedx * 4, z = n_speedz * 4}, + }) + end end end