Carve in openings into dungeons

This commit is contained in:
Wuzzy 2017-05-24 21:39:41 +02:00
parent 73b7e1d550
commit 74a393b1ff

View file

@ -126,7 +126,9 @@ minetest.register_on_generated(function(minp, maxp)
end end
-- Check for air openings (2 stacked air at ground level) in wall positions -- Check for air openings (2 stacked air at ground level) in wall positions
local openings = 0 local openings_counter = 0
-- Store positions of openings; walls will not be generated here
local openings = {}
if ceilingfloor_ok then if ceilingfloor_ok then
local walls = { local walls = {
@ -144,13 +146,16 @@ minetest.register_on_generated(function(minp, maxp)
pos[wall[4]] = wall[5] pos[wall[4]] = wall[5]
pos.y = y+1 pos.y = y+1
if openings[pos.x] == nil then openings[pos.x] = {} end
local door1 = area:index(pos.x, pos.y, pos.z) local door1 = area:index(pos.x, pos.y, pos.z)
pos.y = y+2 pos.y = y+2
local door2 = area:index(pos.x, pos.y, pos.z) local door2 = area:index(pos.x, pos.y, pos.z)
local doorname1 = minetest.get_name_from_content_id(data[door1]) local doorname1 = minetest.get_name_from_content_id(data[door1])
local doorname2 = minetest.get_name_from_content_id(data[door2]) local doorname2 = minetest.get_name_from_content_id(data[door2])
if doorname1 == "air" and doorname2 == "air" then if doorname1 == "air" and doorname2 == "air" then
openings = openings + 1 openings_counter = openings_counter + 1
openings[pos.x][pos.z] = true
end end
end end
end end
@ -158,7 +163,7 @@ minetest.register_on_generated(function(minp, maxp)
end end
-- Check conditions. If okay, start generating -- Check conditions. If okay, start generating
if ceilingfloor_ok and openings >= 1 and openings <= 5 then if ceilingfloor_ok and openings_counter >= 1 and openings_counter <= 5 then
-- Okay! Spawning starts! -- Okay! Spawning starts!
-- First prepare random chest positions. -- First prepare random chest positions.
@ -207,7 +212,11 @@ minetest.register_on_generated(function(minp, maxp)
-- Wall or ceiling -- Wall or ceiling
elseif ty == maxy or (ty > y and (tx == x or tx == maxx) or (tz == z or tz == maxz)) then elseif ty == maxy or (ty > y and (tx == x or tx == maxx) or (tz == z or tz == maxz)) then
-- Check if it's an opening first
if not (ty < maxy-1 and openings[tx][tz] == true) then
data[p_pos] = c_cobble data[p_pos] = c_cobble
end
-- No-op if it was an opening
-- Room interiour -- Room interiour
else else