Extra error checking.
This commit is contained in:
parent
aa999e2ed5
commit
bf26b8bee1
25 changed files with 897 additions and 314 deletions
28
fortress.lua
28
fortress.lua
|
@ -89,7 +89,15 @@ newnode.description = "Treasure Chest"
|
|||
newnode.on_construct = nil
|
||||
newnode.drop = 'default:chest'
|
||||
newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not meta then
|
||||
return
|
||||
end
|
||||
|
||||
local ready = meta:get_string('formspec')
|
||||
if ready == '' then
|
||||
local level = math.max(6, math.ceil(pos.y / math.floor(max_depth / 6)))
|
||||
|
@ -123,6 +131,10 @@ function table.shuffle(self)
|
|||
end
|
||||
|
||||
function unionfind(max)
|
||||
if not (max and type(max) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
local u = { _parent = {}, _rank = {} }
|
||||
|
||||
for i = 0, max-1 do
|
||||
|
@ -164,6 +176,10 @@ end
|
|||
|
||||
|
||||
local function maze_floor(y2, minp, maxp, data, area, node)
|
||||
if not (y2 and minp and maxp and data and area and node and type(y2) == 'number' and type(data) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
-- walls is zero-based.
|
||||
local walls = {}
|
||||
for i = 0, 2 * cells * cells - 1 do
|
||||
|
@ -290,7 +306,12 @@ local designs = {
|
|||
{0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0},
|
||||
},
|
||||
}
|
||||
|
||||
local function design_floor(y2, minp, maxp, data, area, node)
|
||||
if not (y2 and minp and maxp and data and area and node and type(y2) == 'number' and type(data) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
local design = designs[math.random(#designs)]
|
||||
|
||||
local py = minp.y + y2 * cell_size
|
||||
|
@ -341,6 +362,10 @@ end
|
|||
|
||||
|
||||
fun_caves.fortress = function(minp_in, maxp_in, data, area, node)
|
||||
if not (minp_in and maxp_in and data and area and node and type(data) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
-- hungry maze
|
||||
-- chests (w traps)
|
||||
-- step traps (math based)
|
||||
|
@ -357,6 +382,9 @@ fun_caves.fortress = function(minp_in, maxp_in, data, area, node)
|
|||
local treasure_count = 0
|
||||
local csize = vector.add(vector.subtract(maxp_in, minp_in), 1)
|
||||
local floor_1 = minetest.get_perlin_map(floor_noise_1, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp_in.x, y=minp_in.z})
|
||||
if not floor_1 then
|
||||
return
|
||||
end
|
||||
|
||||
for y2 = 0, cells-1 do
|
||||
local floor_type = math.random(20)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue