Bug fixes
parent
588ed956b1
commit
d111364b0f
19
init.lua
19
init.lua
|
@ -291,12 +291,12 @@ function internal.clean_shape_def(def)
|
||||||
return d
|
return d
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get the most nearby cave shape
|
-- Get the most nearby cave biome
|
||||||
function internal.closest_cave_biome(heat, humidity)
|
function internal.closest_cave_biome(heat, humidity)
|
||||||
local biome = internal.default_biome()
|
local biome = internal.default_biome()
|
||||||
local d = internal.biome_def_distance(biome, heat, humidity)
|
local d = internal.biome_def_distance(biome, heat, humidity)
|
||||||
|
|
||||||
for key, def in pairs(noordstar_caves.registered_biomes) do
|
for _, def in pairs(noordstar_caves.registered_biomes) do
|
||||||
local new_d = internal.biome_def_distance(def, heat, humidity)
|
local new_d = internal.biome_def_distance(def, heat, humidity)
|
||||||
|
|
||||||
if new_d <= d then
|
if new_d <= d then
|
||||||
|
@ -305,7 +305,7 @@ function internal.closest_cave_biome(heat, humidity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return shape
|
return biome
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get the most nearby cave shape
|
-- Get the most nearby cave shape
|
||||||
|
@ -453,10 +453,17 @@ function internal.flat_from_cave_bools(minp, maxp)
|
||||||
noise[key] = internal.flat_from_shape_def(shape, minp, maxp)
|
noise[key] = internal.flat_from_shape_def(shape, minp, maxp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local default = internal.default_shape()
|
||||||
|
noise[default.name] = internal.flat_from_shape_def(default, minp, maxp)
|
||||||
|
|
||||||
-- Create a flat array of bools
|
-- Create a flat array of bools
|
||||||
local bools = Flat3dArray:from_func(minp, maxp, function (i, pos)
|
local bools = Flat3dArray:from_func(minp, maxp, function (i, pos)
|
||||||
local key = reduced:get_pos(internal.reduced_shape_pos(pos))
|
local key = reduced:get_pos(internal.reduced_shape_pos(pos))
|
||||||
|
|
||||||
|
if noise[key] == nil then
|
||||||
|
error("Key " .. key .. " gave no value on noise")
|
||||||
|
end
|
||||||
|
|
||||||
local n = noise[key]:get_index(i)
|
local n = noise[key]:get_index(i)
|
||||||
local v = internal.cave_vastness(pos)
|
local v = internal.cave_vastness(pos)
|
||||||
|
|
||||||
|
@ -566,6 +573,8 @@ function internal.flat_from_shape_def(def, minp, maxp)
|
||||||
internal.iter_3d_area(minp, maxp, function (i, pos)
|
internal.iter_3d_area(minp, maxp, function (i, pos)
|
||||||
noise_flat_map[i] = def.func(pos, noise_flat_map[i])
|
noise_flat_map[i] = def.func(pos, noise_flat_map[i])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
return Flat3dArray:new(minp, maxp, noise_flat_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Convert 3d relative coordinates to an index on a flat array
|
-- Convert 3d relative coordinates to an index on a flat array
|
||||||
|
@ -643,9 +652,7 @@ function internal.generate_caves(data, minp, maxp)
|
||||||
local heat = heat_points:get_index(i)
|
local heat = heat_points:get_index(i)
|
||||||
local humidity = humidity_points:get_index(i)
|
local humidity = humidity_points:get_index(i)
|
||||||
|
|
||||||
local name = internal.closest_cave_biome(heat, humidity)
|
local def = internal.closest_cave_biome(heat, humidity)
|
||||||
|
|
||||||
local def = noordstar_caves.registered_biomes[name] or internal.default_biome()
|
|
||||||
|
|
||||||
if nt == internal.node_types.floor then
|
if nt == internal.node_types.floor then
|
||||||
place(def.node_floor)
|
place(def.node_floor)
|
||||||
|
|
Loading…
Reference in New Issue