Skip to content

Commit 720b24e

Browse files
authoredApr 6, 2020
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.
1 parent 4243d28 commit 720b24e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed
 

‎mods/weather/init.lua

+14-6
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,26 @@ local function update_clouds()
8282
nobj_speedx = nobj_speedx or minetest.get_perlin(np_speedx)
8383
nobj_speedz = nobj_speedz or minetest.get_perlin(np_speedz)
8484

85-
local n_density = nobj_density:get_2d({x = time, y = 0})
86-
local n_thickness = nobj_thickness:get_2d({x = time, y = 0})
87-
local n_speedx = nobj_speedx:get_2d({x = time, y = 0})
88-
local n_speedz = nobj_speedz:get_2d({x = time, y = 0})
85+
local n_density = nobj_density:get_2d({x = time, y = 0}) -- 0 to 1
86+
local n_thickness = nobj_thickness:get_2d({x = time, y = 0}) -- 0 to 1
87+
local n_speedx = nobj_speedx:get_2d({x = time, y = 0}) -- -1 to 1
88+
local n_speedz = nobj_speedz:get_2d({x = time, y = 0}) -- -1 to 1
8989

9090
for _, player in ipairs(minetest.get_connected_players()) do
9191
local humid = minetest.get_humidity(player:get_pos())
92+
-- Default and classic density value is 0.4, make this happen
93+
-- at humidity midvalue 50 when n_density is at midvalue 0.5.
94+
-- density_max = 0.25 at humid = 0.
95+
-- density_max = 0.8 at humid = 50.
96+
-- density_max = 1.35 at humid = 100.
97+
local density_max = 0.8 + ((humid - 50) / 50) * 0.55
9298
player:set_clouds({
93-
density = rangelim(humid / 100, 0.25, 1.0) * n_density,
99+
-- Range limit density_max to always have occasional
100+
-- small scattered clouds at extreme low humidity.
101+
density = rangelim(density_max, 0.2, 1.0) * n_density,
94102
thickness = math.max(math.floor(
95103
rangelim(32 * humid / 100, 8, 32) * n_thickness
96-
), 1),
104+
), 2),
97105
speed = {x = n_speedx * 4, z = n_speedz * 4},
98106
})
99107
end

0 commit comments

Comments
 (0)
Please sign in to comment.