Add ctf_barrier
This commit is contained in:
parent
6995373b5a
commit
03769eabf6
3 changed files with 104 additions and 1 deletions
2
mods/ctf_barrier/depends.txt
Normal file
2
mods/ctf_barrier/depends.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
ctf
|
||||
ctf_match
|
101
mods/ctf_barrier/init.lua
Normal file
101
mods/ctf_barrier/init.lua
Normal file
|
@ -0,0 +1,101 @@
|
|||
minetest.register_node("ctf_barrier:ind_glass", {
|
||||
description = "You cheater you!",
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png", "default_glass_detail.png"},
|
||||
inventory_image = minetest.inventorycube("default_glass.png"),
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = true,
|
||||
groups = {immortal = 1},
|
||||
sounds = default.node_sound_glass_defaults()
|
||||
})
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local r = ctf.setting("match.map_reset_limit") - 4
|
||||
|
||||
if not ((minp.x < -r and maxp.x > -r)
|
||||
or (minp.x < r and maxp.x > r)
|
||||
or (minp.y < -r and maxp.x > -r)
|
||||
or (minp.y < r and maxp.x > r)
|
||||
or (minp.z < -r and maxp.z > -r)
|
||||
or (minp.z < r and maxp.z > r)) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Set up voxel manip
|
||||
local t1 = os.clock()
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local a = VoxelArea:new{
|
||||
MinEdge={x=emin.x, y=emin.y, z=emin.z},
|
||||
MaxEdge={x=emax.x, y=emax.y, z=emax.z},
|
||||
}
|
||||
local data = vm:get_data()
|
||||
local c_glass = minetest.get_content_id("ctf_barrier:ind_glass")
|
||||
local c_stone = minetest.get_content_id("ctf_flag:ind_base")
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local dist = 3
|
||||
|
||||
-- Left
|
||||
if minp.x < -r and maxp.x > -r then
|
||||
local x = -r
|
||||
for z = minp.z, maxp.z do
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = a:index(x, y, z)
|
||||
if data[vi] == c_air then
|
||||
data[vi] = c_glass
|
||||
else
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Right
|
||||
if minp.x < r and maxp.x > r then
|
||||
local x = r
|
||||
for z = minp.z, maxp.z do
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = a:index(x, y, z)
|
||||
if data[vi] == c_air then
|
||||
data[vi] = c_glass
|
||||
else
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Front
|
||||
if minp.z < -r and maxp.z > -r then
|
||||
local z = -r
|
||||
for x = minp.x, maxp.x do
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = a:index(x, y, z)
|
||||
if data[vi] == c_air then
|
||||
data[vi] = c_glass
|
||||
else
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Back
|
||||
if minp.z < r and maxp.z > r then
|
||||
local z = r
|
||||
for x = minp.x, maxp.x do
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = a:index(x, y, z)
|
||||
if data[vi] == c_air then
|
||||
data[vi] = c_glass
|
||||
else
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
end)
|
|
@ -1 +1 @@
|
|||
Subproject commit b72072c3ce1d6500f027252168b8f5a59b123eec
|
||||
Subproject commit 37c15d683dcd822019a05bf1e398230daf4f6b3e
|
Loading…
Reference in a new issue