Readd team base

This commit is contained in:
rubenwardy 2018-01-21 23:09:07 +00:00
parent db49f82790
commit 6a53c23f95
4 changed files with 43 additions and 48 deletions

View file

@ -1,4 +1,5 @@
default default
ctf_team_base?
ctf? ctf?
ctf_match? ctf_match?
worldedit? worldedit?

View file

@ -38,6 +38,8 @@ function ctf_map.place_map(map)
minetest.log("error", "Placing " .. value.chests.n .. " chests from " .. minetest.log("error", "Placing " .. value.chests.n .. " chests from " ..
minetest.pos_to_string(value.chests.from) .. " to ".. minetest.pos_to_string(value.chests.from) .. " to "..
minetest.pos_to_string(value.chests.to)) minetest.pos_to_string(value.chests.to))
ctf_team_base.place(value.color, value.pos)
end end
end end

View file

@ -1,5 +1,4 @@
ctf ctf
ctf_flag ctf_flag
ctf_match ctf_match
ctf_barrier
ctf_stats ctf_stats

View file

@ -181,55 +181,48 @@ minetest.register_abm({
end end
}) })
minetest.register_on_generated(function(minp, maxp, seed) ctf_team_base = {}
for tname, team in pairs(ctf.teams) do function ctf_team_base.place(color, pos)
for _, flag in pairs(team.flags) do -- Spawn ind base
if minp.x <= flag.x and maxp.x >= flag.x and for x = pos.x - 2, pos.x + 2 do
minp.y <= flag.y and maxp.y >= flag.y and for z = pos.z - 2, pos.z + 2 do
minp.z <= flag.z and maxp.z >= flag.z then minetest.set_node({ x = x, y = pos.y - 1, z = z},
-- Spawn ind base {name = "default:cobble"})
for x = flag.x - 2, flag.x + 2 do end
for z = flag.z - 2, flag.z + 2 do end
minetest.set_node({ x = x, y = flag.y - 1, z = z}, minetest.set_node({ x = pos.x, y = pos.y - 1, z = pos.z},
{name = "default:cobble"}) {name = "ctf_barrier:ind_stone"})
end
end
minetest.set_node({ x = flag.x, y = flag.y - 1, z = flag.z},
{name = "ctf_barrier:ind_stone"})
-- Check for trees -- Check for trees
for y = flag.y, flag.y + 3 do for y = pos.y, pos.y + 3 do
for x = flag.x - 3, flag.x + 3 do for x = pos.x - 3, pos.x + 3 do
for z = flag.z - 3, flag.z + 3 do for z = pos.z - 3, pos.z + 3 do
local pos = {x=x, y=y, z=z} local pos = {x=x, y=y, z=z}
if minetest.get_node(pos).name == "default:tree" then if minetest.get_node(pos).name == "default:tree" then
minetest.set_node(pos, {name="air"}) minetest.set_node(pos, {name="air"})
end
end
end
end end
-- Spawn chest
local chest = {name = "ctf_team_base:chest_" .. team.data.color}
local dz = 2
if flag.z < 0 then
dz = -2
chest.param2 = minetest.dir_to_facedir({x=0,y=0,z=-1})
end
local pos = {
x = flag.x,
y = flag.y,
z = flag.z + dz
}
minetest.set_node(pos, chest)
local inv = minetest.get_meta(pos):get_inventory()
inv:add_item("main", ItemStack("default:cobble 99"))
inv:add_item("main", ItemStack("default:cobble 99"))
inv:add_item("main", ItemStack("default:cobble 99"))
inv:add_item("main", ItemStack("default:wood 99"))
inv:add_item("main", ItemStack("default:glass 5"))
inv:add_item("main", ItemStack("default:torch 10"))
end end
end end
end end
end)
-- Spawn chest
local chest = {name = "ctf_team_base:chest_" .. color}
local dz = 2
if pos.z < 0 then
dz = -2
chest.param2 = minetest.dir_to_facedir({x=0,y=0,z=-1})
end
local pos = {
x = pos.x,
y = pos.y,
z = pos.z + dz
}
minetest.set_node(pos, chest)
local inv = minetest.get_meta(pos):get_inventory()
inv:add_item("main", ItemStack("default:cobble 99"))
inv:add_item("main", ItemStack("default:cobble 99"))
inv:add_item("main", ItemStack("default:cobble 99"))
inv:add_item("main", ItemStack("default:wood 99"))
inv:add_item("main", ItemStack("default:glass 5"))
inv:add_item("main", ItemStack("default:torch 10"))
end