Replace middle barrier with water if surrounded by water

This commit is contained in:
ClobberXD 2018-11-12 09:36:52 +05:30 committed by rubenwardy
parent 6562959e63
commit 58fe5230d6

View file

@ -4,7 +4,7 @@ local c_glass = minetest.get_content_id("ctf_map:ind_glass")
local c_glass_red = minetest.get_content_id("ctf_map:ind_glass_red") local c_glass_red = minetest.get_content_id("ctf_map:ind_glass_red")
local c_map_ignore = minetest.get_content_id("ctf_map:ignore") local c_map_ignore = minetest.get_content_id("ctf_map:ignore")
local c_actual_st = minetest.get_content_id("default:stone") local c_actual_st = minetest.get_content_id("default:stone")
-- local c_water = minetest.get_content_id("default:water_source") local c_water = minetest.get_content_id("default:water_source")
-- local c_water_f = minetest.get_content_id("default:water_flowing") -- local c_water_f = minetest.get_content_id("default:water_flowing")
local c_air = minetest.get_content_id("air") local c_air = minetest.get_content_id("air")
@ -33,8 +33,17 @@ function ctf_map.remove_middle_barrier()
for x = min.x, max.x do for x = min.x, max.x do
for y = min.y, max.y do for y = min.y, max.y do
local vi = a:index(x, y, 0) local vi = a:index(x, y, 0)
local adj1 = a:index(x, y, 1)
local adj2 = a:index(x, y, -1)
if data[vi] == c_glass_red then if data[vi] == c_glass_red then
-- If surrounding nodes are water, replace node with water
if data[adj1] == c_water and data[adj2] == c_water then
data[vi] = c_water
-- Else replace with air
else
data[vi] = c_air data[vi] = c_air
end
elseif data[vi] == c_stone_red then elseif data[vi] == c_stone_red then
data[vi] = c_actual_st data[vi] = c_actual_st
end end
@ -87,7 +96,7 @@ function ctf_map.place_middle_barrier(center, r, h, direction)
else else
vi = a:index(center.x, y, x) vi = a:index(center.x, y, x)
end end
if data[vi] == c_air then if data[vi] == c_air or data[vi] == c_water then
data[vi] = c_glass_red data[vi] = c_glass_red
end end
end end