Compare commits

..

No commits in common. "b1dbac00d3de1500d1f3263ac5a47b25df6546e7" and "312ab54a46dc4c4f33ba91ce8367f37a9fa10fc2" have entirely different histories.

1 changed files with 69 additions and 146 deletions

215
init.lua
View File

@ -321,7 +321,7 @@ function internal.clean_deco_def(def)
place("height", "number", 1)
place("place_offset_y", "number", 0)
place("replacements", "table", {})
place("flags", "string", "place_center_x,place_center_z")
place("flags", "string", "")
place("rotation", "string", "0")
d.height = math.max(d.height , 0)
@ -575,11 +575,6 @@ function internal.flat_from_node_types(bools, minp, maxp)
return nt.floor_deco
end
if bools:get_index(i + bools.up) == false then
-- Block is near the ceiling
return nt.ceiling_deco
end
return nt.air
else
-- NOT PART OF CAVE
@ -698,8 +693,6 @@ function internal.generate_caves(data, minp, maxp)
-- Get cave bools
local bools = internal.flat_from_cave_bools(bminp, bmaxp)
timer.checkpoint("Calculate cave shape")
-- Get node types
local nts = internal.flat_from_node_types(bools, bminp, bmaxp)
@ -711,8 +704,6 @@ function internal.generate_caves(data, minp, maxp)
internal.humidity_noise_params(), bminp, bmaxp
)
timer.checkpoint("Calculate block types & biomes")
local air = minetest.get_content_id("air")
local schems = {}
@ -750,12 +741,8 @@ function internal.generate_caves(data, minp, maxp)
place(def.node_wall)
elseif nt == internal.node_types.ceiling then
place(def.node_roof)
elseif nt == internal.node_types.floor_deco or nt == internal.node_types.ceiling_deco then
elseif nt == internal.node_types.floor_deco then
local schem_placed = false
local appropriate_place = "floor"
if nt == internal.node_types.ceiling_deco then
appropriate_place = "ceiling"
end
if not schem_placed then
-- Prevent decorations from spawning in the air
@ -766,7 +753,7 @@ function internal.generate_caves(data, minp, maxp)
if not schem_placed then
for _, deco in ipairs(noordstar_caves.registered_decorations) do
if deco.place_on ~= appropriate_place then
if deco.place_on ~= "floor" then
elseif math.random() > deco.fill_ratio then
elseif not internal.is_deco_biome(deco, def.name) then
else
@ -778,12 +765,7 @@ function internal.generate_caves(data, minp, maxp)
end
if not schem_placed then
local n = "air"
if nt == internal.node_types.floor_deco then
n = def.node_dust or n
end
place(n)
schem_placed = true
place(def.node_dust or "air")
end
else
error(
@ -927,42 +909,16 @@ end
-- Place all schematic decorations into the world
function internal.place_schematic_decorations(vmanip, schems)
for _, schem in ipairs(schems) do
local pos = {
x = schem.pos.x,
y = schem.pos.y + schem.deco.place_offset_y,
z = schem.pos.z,
}
local pos = schem.pos
local deco = schem.deco
if deco.deco_type ~= "schematic" then
else
if deco.place_on == "floor" then
minetest.place_schematic_on_vmanip(
vmanip, pos,
deco.schematic, deco.rotation, deco.replacement,
true, deco.flags
)
elseif deco.place_on == "ceiling" then
local h = deco.schematic
if type(deco.schematic) == "string" then
h = minetest.read_schematic(h, {})
if type(h) == "nil" then
error("Could not find schematic! Perhaps it the filename is incorrect?")
end
end
h = h.size.y
minetest.place_schematic_on_vmanip(
vmanip, { x = pos.x, y = pos.y - h + 1, z = pos.z },
deco.schematic, deco.rotation, deco.replacement,
true, deco.flags
)
else
error("Unknown place_on value `" .. deco.place_on .. "`")
end
minetest.place_schematic_on_vmanip(
vmanip, pos,
deco.schematic, deco.rotation, deco.replacement,
true, deco.flags
)
end
end
end
@ -971,11 +927,7 @@ end
function internal.place_simple_decorations(flat, schems)
for _, schem in ipairs(schems) do
if schem.deco.deco_type == "simple" then
local pos = {
x = schem.pos.x,
y = schem.pos.y + schem.deco.place_offset_y,
z = schem.pos.z,
}
local pos = schem.pos
local deco = schem.deco
local i = flat:pos_to_index(pos)
@ -1224,15 +1176,10 @@ end
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
minetest.register_on_generated(function(minp, maxp, blockseed)
timer.start()
math.randomseed(blockseed)
local vm = minetest.get_mapgen_object("voxelmanip")
local data = vm:get_data()
local flat, schems = internal.generate_caves(data, minp, maxp)
timer.checkpoint("Place caves")
local flat, schems = internal.generate_caves(vm:get_data(), minp, maxp)
internal.place_simple_decorations(flat, schems)
@ -1240,9 +1187,6 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
vm:write_to_map()
internal.place_schematic_decorations(vm, schems)
timer.checkpoint("Place decorations")
timer.stop()
end)
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
@ -1287,104 +1231,84 @@ noordstar_caves.register_shape({
connectivity_point = 10,
verticality_point = 40,
})
noordstar_caves.register_shape({
name = "noordstar_caves:cliffs",
-- noordstar_caves.register_shape({
-- name = "noordstar_caves:cliffs",
noise_params = {
offset = 0.4,
scale = 0.5,
spread = { x = 20, y = 100, z = 20 },
seed = 97354,
octaves = 4,
persistence = 0.6,
lacunarity = 2.0,
flags = ""
},
-- noise_params = {
-- offset = 0.4,
-- scale = 0.5,
-- spread = { x = 20, y = 100, z = 20 },
-- seed = 97354,
-- octaves = 4,
-- persistence = 0.6,
-- lacunarity = 2.0,
-- flags = ""
-- },
func = function(pos, n)
return n
end,
-- func = function(pos, n)
-- return n
-- end,
connectivity_point = 30,
verticality_point = 80,
})
noordstar_caves.register_shape({
name = "noordstar_caves:donuts",
-- connectivity_point = 30,
-- verticality_point = 80,
-- })
-- noordstar_caves.register_shape({
-- name = "noordstar_caves:donuts",
noise_params = {
offset = 0.0,
scale = 1.0,
spread = { x = 30, y = 30, z = 30 },
seed = 3934,
octaves = 1,
persistence = 0.6,
lacunarity = 2.0,
flags = "eased"
},
-- noise_params = {
-- offset = 0.0,
-- scale = 1.0,
-- spread = { x = 30, y = 30, z = 30 },
-- seed = 3934,
-- octaves = 1,
-- persistence = 0.6,
-- lacunarity = 2.0,
-- flags = "eased"
-- },
func = function(pos, n)
return 1 - 2 * math.abs(n)^0.5
end,
-- func = function(pos, n)
-- return 1 - 2 * math.abs(n)^0.5
-- end,
connectivity_point = 50,
verticality_point = 40,
})
noordstar_caves.register_shape({
name = "noordstar_caves:wall",
-- connectivity_point = 50,
-- verticality_point = 40,
-- })
-- noordstar_caves.register_shape({
-- name = "noordstar_caves:wall",
func = function(pos, n)
return -0.5
end,
-- func = function(pos, n)
-- return -0.5
-- end,
connectivity_point = 0,
verticality_point = 0,
})
-- connectivity_point = 0,
-- verticality_point = 0,
-- })
-- noordstar_caves.set_world_depth(-60)
-- noordstar_caves.cave_vastness = function(pos) return math.abs(pos.y - 60) / 120 end
noordstar_caves.register_biome({
name = "nc:glowing_floor",
name = "test",
node_floor = "mcl_core:crying_obsidian",
node_wall = "mcl_core:sand",
node_roof = "mcl_ocean:sea_lantern",
node_dust = "mcl_core:snow",
heat_point = 20,
humidity_point = 0,
heat_point = 80,
humidity_point = 80,
})
noordstar_caves.register_biome({
name = "nc:crazy_glowin_walls",
name = "test2",
node_floor = "mcl_amethyst:amethyst_block",
node_wall = "mcl_crimson:shroomlight",
node_roof = "mcl_colorblocks:glazed_terracotta_silver",
heat_point = 100,
humidity_point = 0,
})
noordstar_caves.register_biome({
name = "nc:regular",
heat_point = 50,
humidity_point = 50,
})
noordstar_caves.register_biome({
name = "nc:cold",
node_dust = "mcl_core:snow",
node_roof = "mcl_core:ice",
heat_point = 10,
humidity_point = 100,
})
noordstar_caves.register_biome({
name = "nc:grass",
node_floor = "mcl_core:dirt_with_grass",
heat_point = 50,
humidity_point = 70,
})
noordstar_caves.register_biome({
name = "nc:dangerous_lava",
node_floor = "mcl_core:lava_source",
y_max = -40,
heat_point = 100,
humidity_point = 100,
})
-- noordstar_caves.register_biome({
-- name = "test3",
-- heat_point = 50,
-- humidity_point = 50,
-- })
noordstar_caves.register_decoration({
deco_type = "simple",
@ -1393,22 +1317,21 @@ noordstar_caves.register_decoration({
decoration = "mcl_core:cactus",
height = 3,
height_max = 8,
biomes = { "nc:glowing_floor" },
biomes = { "test" },
})
noordstar_caves.register_decoration({
deco_type = "simple",
place_on = "ceiling",
place_on = "floor",
fill_ratio = 0.1,
decoration = "mcl_ocean:sea_lantern",
height = 1,
height_max = 4,
biomes = { "nc:crazy_glowin_walls" },
place_offset_y = -3,
biomes = { "test2" },
})
noordstar_caves.register_decoration({
deco_type = "schematic",
place_on = "floor",
fill_ratio = 0.001,
fill_ratio = 0.005,
schematic = squeak,
rotation = "random",
-- place_offset_y = 5,