From 720b24ed2d03d84f33427dc75bea0684a36b68c5 Mon Sep 17 00:00:00 2001 From: Paramat Date: Mon, 6 Apr 2020 21:05:07 +0100 Subject: [PATCH] Weather mod: Tune cloud density variation Previously, cloud density was too low at medium humidity. Tune cloud density variation to match the default/classic value at humidity midvalue 50. Tune the lower limit of cloud density that occurs at extreme low humidity. Increase minimum cloud thickness to 2 nodes. Add comments. --- mods/weather/init.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mods/weather/init.lua b/mods/weather/init.lua index c0d1098f..3b9a305a 100644 --- a/mods/weather/init.lua +++ b/mods/weather/init.lua @@ -82,18 +82,26 @@ local function update_clouds() nobj_speedx = nobj_speedx or minetest.get_perlin(np_speedx) nobj_speedz = nobj_speedz or minetest.get_perlin(np_speedz) - local n_density = nobj_density:get_2d({x = time, y = 0}) - local n_thickness = nobj_thickness:get_2d({x = time, y = 0}) - local n_speedx = nobj_speedx:get_2d({x = time, y = 0}) - local n_speedz = nobj_speedz:get_2d({x = time, y = 0}) + local n_density = nobj_density:get_2d({x = time, y = 0}) -- 0 to 1 + local n_thickness = nobj_thickness:get_2d({x = time, y = 0}) -- 0 to 1 + local n_speedx = nobj_speedx:get_2d({x = time, y = 0}) -- -1 to 1 + local n_speedz = nobj_speedz:get_2d({x = time, y = 0}) -- -1 to 1 for _, player in ipairs(minetest.get_connected_players()) do local humid = minetest.get_humidity(player:get_pos()) + -- Default and classic density value is 0.4, make this happen + -- at humidity midvalue 50 when n_density is at midvalue 0.5. + -- density_max = 0.25 at humid = 0. + -- density_max = 0.8 at humid = 50. + -- density_max = 1.35 at humid = 100. + local density_max = 0.8 + ((humid - 50) / 50) * 0.55 player:set_clouds({ - density = rangelim(humid / 100, 0.25, 1.0) * n_density, + -- Range limit density_max to always have occasional + -- small scattered clouds at extreme low humidity. + density = rangelim(density_max, 0.2, 1.0) * n_density, thickness = math.max(math.floor( rangelim(32 * humid / 100, 8, 32) * n_thickness - ), 1), + ), 2), speed = {x = n_speedx * 4, z = n_speedz * 4}, }) end -- 2.25.1