mt-mods / biome_lib

Other
2 stars 5 forks source link

Humidity #3

Closed JordanL2 closed 2 years ago

JordanL2 commented 2 years ago

I think there's something wrong with humidity. According to the API.txt:

A value of +1.0 is very moist (basically a thick fog, if it could be seen), a
value of roughly +0.25 represents the edge of a desert as usually seen in the
game, and a value of -1.0 is as dry as a bone.

This lines up with my observations, with jungles and forests having a higher humidity number and savannas/deserts having much lower. However, I also read this in the API.txt which contradicts it:

humidity_min = num, -- Minimum humidity for the plant to spawn in. Like
                        -- the temperature map, this is a Perlin value where
                        -- lower numbers mean more humidity in the area.
                        -- Defaults to +1 (0% humidity).

These lines in api.lua also that a lower humidity value means more humid:

 90:  biome.humidity_min = biome.humidity_min or 1
 91:  biome.humidity_max = biome.humidity_max or -1
216:    and humidity <= biome.humidity_min and humidity >= biome.humidity_max
567:        and humidity <= biome.humidity_min and humidity >= biome.humidity_max

This is causing an issue with the vines mod, where the vines have a humidity_min of 0.2-0.7, meaning they only appear near deserts, which I think isn't intentional. Should the vines specify humidity_max instead?

JordanL2 commented 2 years ago

I think the functionality changed with this commit: https://github.com/mt-mods/biome_lib/commit/0837ff7fd2658e6e5c311a1a5df6e87e33d6b63a

That switched the code to returning data from minetest.get_biome_data() if it's available, which uses a higher-number-is-more-humid scheme:

        heat_point = 0,
        humidity_point = 50,
    --  ^ Characteristic temperature and humidity for the biome.
    --  ^ These values create 'biome points' on a voronoi diagram with heat and
    --  ^ humidity as axes. The resulting voronoi cells determine the
    --  ^ distribution of the biomes.
    --  ^ Heat and humidity have average values of 50, vary mostly between
    --  ^ 0 and 100 but can exceed these values.

https://github.com/minetest/minetest/blob/ca8ec46843da054e656d2f63b23d0b1695c023da/doc/lua_api.txt#L5985

Since this function was added in 5.0.0, perhaps we can assume this function will always be there and update the code to fix the humidity_min and humidity_max conditions?

BuckarooBanzay commented 2 years ago

Since this function was added in 5.0.0, perhaps we can assume this function will always be there and update the code to fix the humidity_min and humidity_max conditions?

Sounds good, but what about backwards compatibility?

JordanL2 commented 2 years ago

Since this function was added in 5.0.0, perhaps we can assume this function will always be there and update the code to fix the humidity_min and humidity_max conditions?

Sounds good, but what about backwards compatibility?

That's what I'm not sure of, are many people using Minetest < 5.0? If so I'll do my best to make the numbers from get_biome_data be roughly the same range (and positivity) as the old biome_lib data.

EDIT: biome_lib already forces usage of Minetest 5.2:

min_minetest_version = 5.2.0
JordanL2 commented 2 years ago

Unless you meant compatibility of mods using biome_lib - in which case the same solution applies really.

I think it's a matter of changing (pseudocode) get_biome_data() / 100 to 1 - (get_biome_data() / 100).

JordanL2 commented 2 years ago

Raised this PR, I think we also need to look at bushes_classic, ferns and flowers_plus and check they're working as they use the temperature and humidity values and I'm not seeing many of them.

I'm working on the vines mod to reenable humidity and set sensible temperature settings.

https://github.com/mt-mods/biome_lib/pull/5

JordanL2 commented 2 years ago

Raised this PR for the humidity/temperature settings for vines (along with a few other fixes): https://github.com/mt-mods/plantlife_modpack/pull/4

I've seen enough ferns and lilies from flowers plus to be confident they're working. Also bushes_classic spawns the bushes slowly over time, that also seems to be working.