Flood every 8th pyramid with sand

This commit is contained in:
Wuzzy 2019-08-20 02:58:37 +02:00
parent d3187e4a08
commit acc22a5576
2 changed files with 44 additions and 7 deletions

View File

@ -89,11 +89,17 @@ local function underground(pos, stone, sand)
end
end
local function make_entrance(pos, brick)
local function make_entrance(pos, brick, sand, flood_sand)
local gang = {x=pos.x+10,y=pos.y, z=pos.z}
for iy=2,3,1 do
for iz=0,6,1 do
minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
local max_sand_height = math.random(1,3)
for iz=0,6,1 do
local sand_height = math.random(1,max_sand_height)
for iy=2,3,1 do
if flood_sand and iy <= sand_height and iz >= 3 then
minetest.set_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz}, {name=sand})
else
minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
end
if iz >=3 and iy == 3 then
minetest.set_node({x=gang.x,y=gang.y+iy+1,z=gang.z+iz}, {name=brick})
minetest.set_node({x=gang.x+1,y=gang.y+iy+1,z=gang.z+iz}, {name=brick})
@ -118,9 +124,9 @@ local function make(pos, brick, sandstone, stone, sand, ptype, room_id)
end
end
end
local ok, msg = tsm_pyramids.make_room(pos, ptype, room_id)
local ok, msg, flood_sand = tsm_pyramids.make_room(pos, ptype, room_id)
add_spawner({x=pos.x+11,y=pos.y+2, z=pos.z+17})
make_entrance({x=pos.x,y=pos.y, z=pos.z}, brick)
make_entrance({x=pos.x,y=pos.y, z=pos.z}, brick, sand, flood_sand)
minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
return ok, msg
end

View File

@ -643,7 +643,14 @@ function tsm_pyramids.make_room(pos, stype, room_id)
if room.traps then
tsm_pyramids.make_traps(pos, stype)
end
return true
local sanded = false
if room.flood_sand ~= false then
if math.random(1,8) == 1 then
tsm_pyramids.flood_sand(pos, stype)
sanded = true
end
end
return true, nil, sanded
end
local shuffle_traps = function(chance)
@ -676,3 +683,27 @@ function tsm_pyramids.make_traps(pos, stype)
end
end
end
function tsm_pyramids.flood_sand(pos, stype)
local nn = "default:sand"
if stype == "desert" then
nn = "default:desert_sand"
end
local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
local maxh = math.random(1,4)
local chance = math.random(1,7)
for ix=0,8,1 do
for iz=0,8,1 do
if math.random(1,chance) == 1 then
local h = math.random(1,maxh)
for iy=0,h,1 do
local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
if minetest.get_node(p).name == "air" then
minetest.set_node(p, {name=nn})
end
end
end
end
end
end