1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-22 23:10:17 +01:00

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.
This commit is contained in:
Paramat 2020-04-06 21:05:07 +01:00 committed by GitHub
parent 4243d28846
commit 720b24ed2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,18 +82,26 @@ local function update_clouds()
nobj_speedx = nobj_speedx or minetest.get_perlin(np_speedx) nobj_speedx = nobj_speedx or minetest.get_perlin(np_speedx)
nobj_speedz = nobj_speedz or minetest.get_perlin(np_speedz) nobj_speedz = nobj_speedz or minetest.get_perlin(np_speedz)
local n_density = nobj_density: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}) 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}) 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}) local n_speedz = nobj_speedz:get_2d({x = time, y = 0}) -- -1 to 1
for _, player in ipairs(minetest.get_connected_players()) do for _, player in ipairs(minetest.get_connected_players()) do
local humid = minetest.get_humidity(player:get_pos()) 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({ 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( thickness = math.max(math.floor(
rangelim(32 * humid / 100, 8, 32) * n_thickness rangelim(32 * humid / 100, 8, 32) * n_thickness
), 1), ), 2),
speed = {x = n_speedx * 4, z = n_speedz * 4}, speed = {x = n_speedx * 4, z = n_speedz * 4},
}) })
end end