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