Add fallback noises when Minetest doesn't give it
parent
0534c38150
commit
6d5b5fe673
4
API.md
4
API.md
|
@ -10,13 +10,9 @@ 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.
|
||||
|
|
34
init.lua
34
init.lua
|
@ -19,6 +19,28 @@ local seed = tonumber(minetest.get_mapgen_setting("seed")) or 0
|
|||
|
||||
local mgv6_perlin_biome, mgv6_perlin_humidity, mgv6_np_biome
|
||||
|
||||
-- v6 default noiseparams are hardcoded here because Minetest doesn't give us those
|
||||
local mgv6_np_biome_default = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = { x = 500, y = 500, z = 500},
|
||||
seed = 9130,
|
||||
octaves = 3,
|
||||
persistence = 0.50,
|
||||
lacunarity = 2.0,
|
||||
flags = "eased",
|
||||
}
|
||||
local mgv6_np_humidity_default = {
|
||||
offset = 0.5,
|
||||
scale = 0.5,
|
||||
spread = { x = 500, y = 500, z = 500},
|
||||
seed = 72384,
|
||||
octaves = 3,
|
||||
persistence = 0.50,
|
||||
lacunarity = 2.0,
|
||||
flags = "eased",
|
||||
}
|
||||
|
||||
local v6_flags_str = minetest.get_mapgen_setting("mgv6_spflags")
|
||||
if v6_flags_str == nil then
|
||||
v6_flags_str = ""
|
||||
|
@ -86,15 +108,19 @@ biomeinfo.all_v6_biomes = {
|
|||
local function init_perlins()
|
||||
if not mgv6_perlin_biome then
|
||||
mgv6_np_biome = minetest.get_mapgen_setting_noiseparams("mgv6_np_biome")
|
||||
if mgv6_np_biome then
|
||||
mgv6_perlin_biome = minetest.get_perlin(mgv6_np_biome)
|
||||
if not mgv6_np_biome then
|
||||
mgv6_np_biome = mgv6_np_biome_default
|
||||
minetest.log("action", "[biomeinfo] Using hardcoded mgv6_np_biome default")
|
||||
end
|
||||
mgv6_perlin_biome = minetest.get_perlin(mgv6_np_biome)
|
||||
end
|
||||
if not mgv6_perlin_humidity then
|
||||
local np_humidity = minetest.get_mapgen_setting_noiseparams("mgv6_np_humidity")
|
||||
if np_humidity then
|
||||
mgv6_perlin_humidity = minetest.get_perlin(np_humidity)
|
||||
if not np_humidity then
|
||||
np_humidity = mgv6_np_humidity_default
|
||||
minetest.log("action", "[biomeinfo] Using hardcoded mgv6_np_humidity default")
|
||||
end
|
||||
mgv6_perlin_humidity = minetest.get_perlin(np_humidity)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue