diff --git a/API.txt b/API.txt index 07715fd..61c4532 100644 --- a/API.txt +++ b/API.txt @@ -250,7 +250,11 @@ biome = { -- skipped. Avoid using excessively large radii. rarity = num, -- How rare should this object be in its biome? Larger -- values make objects more rare, via: - -- math.random(1,100) > this + -- math.random() * 100 > this + rarity_fertility -- The amount that the rarity is reduced by fertility. + = num, -- This makes the rarity field the upper bound for + -- rarity, and (rarity - rarity_fertility) the lower + -- bound. Defaults to 0. max_count = num, -- The absolute maximum number of your object that -- should be allowed to spawn in a 5x5x5 mapblock area -- (80x80x80 nodes). Defaults to 5, but be sure you diff --git a/api.lua b/api.lua index f000e9e..352b56b 100644 --- a/api.lua +++ b/api.lua @@ -73,6 +73,7 @@ function biome_lib.set_defaults(biome) biome.near_nodes_size = biome.near_nodes_size or 0 biome.near_nodes_count = biome.near_nodes_count or 1 biome.rarity = biome.rarity or 50 + biome.rarity_fertility = biome.rarity_fertility or 0 biome.max_count = biome.max_count or 125 biome.tries = biome.tries or 2 if biome.check_air ~= false then biome.check_air = true end @@ -183,14 +184,18 @@ end local function populate_single_surface(biome, pos, perlin_fertile_area, checkair) local p_top = { x = pos.x, y = pos.y + 1, z = pos.z } - if math.random(1, 100) <= biome.rarity then + if biome.rarity - biome.rarity_fertility == 100 then return end local fertility, temperature, humidity = get_biome_data(pos, perlin_fertile_area) + if math.random() * 100 <= (biome.rarity - ((fertility + 1) / 2 * biome.rarity_fertility)) then + return + end + local pos_biome_ok = pos.y >= biome.min_elevation and pos.y <= biome.max_elevation - and fertility > biome.plantlife_limit + and fertility >= biome.plantlife_limit and temperature <= biome.temp_min and temperature >= biome.temp_max and humidity <= biome.humidity_min and humidity >= biome.humidity_max