move test caves to base:demo

This commit is contained in:
MihailRis
2024-10-08 20:14:38 +03:00
parent 5966ca5617
commit c022e11c3b
4 changed files with 30 additions and 24 deletions
@@ -1,3 +1,13 @@
-- Get entry-point and filename from `entry-point:filename` path
-- // TODO: move to stdmin
function parse_path(path)
local index = string.find(path, ':')
if index == nil then
error("invalid path syntax (':' missing)")
end
return string.sub(path, 1, index-1), string.sub(path, index+1, -1)
end
local _, dir = parse_path(__DIR__)
ores = file.read_combined_list(dir.."/ores.json")
@@ -26,6 +36,17 @@ end
function place_structures(x, z, w, d, seed, hmap, chunk_height)
local placements = {}
place_ores(placements, x, z, w, d, seed, hmap, chunk_height)
if math.random() < 0.1 then -- generate caves
local sy = math.random() * (chunk_height / 2)
local ey = math.random() * (chunk_height / 2)
local sx = x + math.random() * 20 - 10
local ex = x + math.random() * 20 - 10
local sz = z + math.random() * 20 - 10
local ez = z + math.random() * 20 - 10
table.insert(placements,
{":line", 0, {sx - 10, sy, sz - 10}, {ex + 10, ey, ez + 10}, 3})
end
return placements
end