Make 2 functions return nil on fail

This commit is contained in:
Wuzzy 2020-01-01 23:35:08 +01:00
parent 3b6c56dbed
commit 75616e5d2a
2 changed files with 10 additions and 0 deletions

4
API.md
View File

@ -10,9 +10,13 @@ If you use these in any other mapgen, bad things might happen.
### `biomeinfo.get_v6_humidity(pos)`
Get the biome humidity at pos (for v6 mapgen).
This function might fail and return nil.
### `biomeinfo.get_v6_heat(pos)`
Get the biome heat/temperature at pos (for v6 mapgen).
This function might fail and return nil.
### `biomeinfo.get_v6_biome(pos)`
Get the v6 biome at pos.
Returns a string, which is the unique biome name.

View File

@ -112,6 +112,9 @@ end
function biomeinfo.get_v6_heat(pos)
init_perlins()
if not mgv6_perlin_biome then
return nil
end
local bpos = vector.floor(pos)
-- The temperature noise needs a special offset (see calculateNoise in mapgen_v6.cpp)
return mgv6_perlin_biome:get_2d({x=bpos.x + mgv6_np_biome.spread.x*0.6, y=bpos.z + mgv6_np_biome.spread.z*0.2})
@ -119,6 +122,9 @@ end
function biomeinfo.get_v6_humidity(pos)
init_perlins()
if not mgv6_perlin_humidity then
return nil
end
local bpos = vector.floor(pos)
return mgv6_perlin_humidity:get_2d({x=bpos.x, y=bpos.z})
end