Extra error checking.
This commit is contained in:
parent
aa999e2ed5
commit
bf26b8bee1
25 changed files with 897 additions and 314 deletions
40
mapgen.lua
40
mapgen.lua
|
@ -8,9 +8,14 @@ local fortress_noise = {offset = 0, scale = 1, seed = -4082, spread = {x = 7, y
|
|||
-- This tables looks up nodes that aren't already stored.
|
||||
local node = setmetatable({}, {
|
||||
__index = function(t, k)
|
||||
if not (t and k and type(t) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
t[k] = minetest.get_content_id(k)
|
||||
return t[k]
|
||||
end})
|
||||
end
|
||||
})
|
||||
|
||||
local data = {}
|
||||
local p2data = {} -- vm rotation data buffer
|
||||
|
@ -41,6 +46,10 @@ end
|
|||
--end
|
||||
|
||||
fun_caves.is_fortress = function(pos, cs)
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
|
||||
-- Fix this to get csize, somehow.
|
||||
-- Remember that this function may be called
|
||||
-- before any chunks are generated.
|
||||
|
@ -60,6 +69,10 @@ fun_caves.is_fortress = function(pos, cs)
|
|||
local z = math.floor((pos.z + offset) / cs.z)
|
||||
|
||||
local n = minetest.get_perlin(fortress_noise):get3d({x=x, y=y, z=z})
|
||||
if not (n and type(n) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
if math.floor((n * 10000) % (fun_caves.DEBUG and 4 or 19)) == 1 then
|
||||
return true
|
||||
end
|
||||
|
@ -68,6 +81,10 @@ fun_caves.is_fortress = function(pos, cs)
|
|||
end
|
||||
|
||||
fun_caves.place_schematic = function(minp, maxp, data, p2data, area, node, pos, schem, center)
|
||||
if not (minp and maxp and data and p2data and area and node and pos and schem and type(data) == 'table' and type(p2data) == 'table' and type(schem) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
local rot = math.random(4) - 1
|
||||
local yslice = {}
|
||||
if schem.yslice_prob then
|
||||
|
@ -119,6 +136,10 @@ fun_caves.place_schematic = function(minp, maxp, data, p2data, area, node, pos,
|
|||
end
|
||||
|
||||
fun_caves.surround = function(node, data, area, ivm)
|
||||
if not (node and data and area and ivm and type(data) == 'table' and type(ivm) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
-- Check to make sure that a plant root is fully surrounded.
|
||||
-- This is due to the kludgy way you have to make water plants
|
||||
-- in minetest, to avoid bubbles.
|
||||
|
@ -345,8 +366,16 @@ fun_caves.cave_biomes = {
|
|||
|
||||
|
||||
local function generate(p_minp, p_maxp, seed)
|
||||
if not (p_minp and p_maxp and seed) then
|
||||
return
|
||||
end
|
||||
|
||||
local minp, maxp = p_minp, p_maxp
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
if not (vm and emin and emax) then
|
||||
return
|
||||
end
|
||||
|
||||
vm:get_data(data)
|
||||
p2data = vm:get_param2_data()
|
||||
local heightmap
|
||||
|
@ -358,7 +387,14 @@ local function generate(p_minp, p_maxp, seed)
|
|||
end
|
||||
|
||||
-- use the same seed (based on perlin noise).
|
||||
math.randomseed(minetest.get_perlin(seed_noise):get2d({x=minp.x, y=minp.z}))
|
||||
do
|
||||
local seed = minetest.get_perlin(seed_noise):get2d({x=minp.x, y=minp.z})
|
||||
if not (seed and type(seed) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
math.randomseed(seed)
|
||||
end
|
||||
|
||||
local write = false
|
||||
local write_p2, write_p4 = false, false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue