Make 2 functions return nil on fail
This commit is contained in:
parent
3b6c56dbed
commit
75616e5d2a
4
API.md
4
API.md
@ -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.
|
||||
|
6
init.lua
6
init.lua
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user