Localize variables. Prevent shafts from damaging trees.

This commit is contained in:
Duane 2016-08-02 04:56:42 -05:00
parent 61c3cb0edd
commit 2270e87a71
2 changed files with 11 additions and 9 deletions

View file

@ -186,10 +186,10 @@ fun_caves.dungeon = function(minp_in, maxp_in, data, p2data, area, node, heightm
else else
t = 44 - z t = 44 - z
end end
t = math.floor(t / 44 * 22) t = math.floor(t / 44 * 10)
if x < 2 or x > 9 or z < 2 or z > 9 then if x < 2 or x > 9 or z < 2 or z > 9 then
if math.floor((y - minp.y) % 22) == t then if math.floor((y - minp.y) % 10) == t then
data[ivm] = node['default:cobble'] data[ivm] = node['default:cobble']
else else
data[ivm] = node['air'] data[ivm] = node['air']
@ -210,10 +210,10 @@ fun_caves.dungeon = function(minp_in, maxp_in, data, p2data, area, node, heightm
return return
end end
minp = table.copy(minp_in) local minp = table.copy(minp_in)
minp.x = minp.x + 10 minp.x = minp.x + 10
minp.z = minp.z + 10 minp.z = minp.z + 10
maxp = table.copy(maxp_in) local maxp = table.copy(maxp_in)
maxp.x = maxp.x - 9 maxp.x = maxp.x - 9
maxp.z = maxp.z - 9 maxp.z = maxp.z - 9
local level = math.min(6, math.ceil(maxp.y / math.floor(max_depth / -6))) local level = math.min(6, math.ceil(maxp.y / math.floor(max_depth / -6)))
@ -381,5 +381,5 @@ fun_caves.dungeon = function(minp_in, maxp_in, data, p2data, area, node, heightm
end end
end end
return true, true return true, true, true
end end

View file

@ -430,18 +430,20 @@ local function generate(p_minp, p_maxp, seed)
end end
if fun_caves.dungeon then if fun_caves.dungeon then
write, write_p2 = fun_caves.dungeon(minp, maxp, data, p2data, area, node, heightmap) local full
if write then write, write_p2, full = fun_caves.dungeon(minp, maxp, data, p2data, area, node, heightmap)
if write and full then
break break
end end
end end
if fun_caves.cavegen and fun_caves.decogen then if fun_caves.cavegen and fun_caves.decogen then
local h2 local h2, write_cave
write, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone, ground_nodes) write_cave, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone, ground_nodes)
if h2 then if h2 then
heightmap = h2 heightmap = h2
end end
write = write or write_cave
local biomemap local biomemap
if fun_caves.use_bi_hi then if fun_caves.use_bi_hi then