From 6a53c23f95ca7b2a0e2abc989b93303a4a8aca0a Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 21 Jan 2018 23:09:07 +0000 Subject: [PATCH] Readd team base --- mods/ctf_map/depends.txt | 1 + mods/ctf_map/schem_map.lua | 2 + mods/ctf_team_base/depends.txt | 1 - mods/ctf_team_base/init.lua | 87 ++++++++++++++++------------------ 4 files changed, 43 insertions(+), 48 deletions(-) diff --git a/mods/ctf_map/depends.txt b/mods/ctf_map/depends.txt index 83ff9dc..dbb1d69 100644 --- a/mods/ctf_map/depends.txt +++ b/mods/ctf_map/depends.txt @@ -1,4 +1,5 @@ default +ctf_team_base? ctf? ctf_match? worldedit? diff --git a/mods/ctf_map/schem_map.lua b/mods/ctf_map/schem_map.lua index 2113d2a..b5b9dbb 100644 --- a/mods/ctf_map/schem_map.lua +++ b/mods/ctf_map/schem_map.lua @@ -38,6 +38,8 @@ function ctf_map.place_map(map) minetest.log("error", "Placing " .. value.chests.n .. " chests from " .. minetest.pos_to_string(value.chests.from) .. " to ".. minetest.pos_to_string(value.chests.to)) + + ctf_team_base.place(value.color, value.pos) end end diff --git a/mods/ctf_team_base/depends.txt b/mods/ctf_team_base/depends.txt index a0d3d36..1882da9 100644 --- a/mods/ctf_team_base/depends.txt +++ b/mods/ctf_team_base/depends.txt @@ -1,5 +1,4 @@ ctf ctf_flag ctf_match -ctf_barrier ctf_stats diff --git a/mods/ctf_team_base/init.lua b/mods/ctf_team_base/init.lua index 55935f9..1b4a67c 100644 --- a/mods/ctf_team_base/init.lua +++ b/mods/ctf_team_base/init.lua @@ -181,55 +181,48 @@ minetest.register_abm({ end }) -minetest.register_on_generated(function(minp, maxp, seed) - for tname, team in pairs(ctf.teams) do - for _, flag in pairs(team.flags) do - if minp.x <= flag.x and maxp.x >= flag.x and - minp.y <= flag.y and maxp.y >= flag.y and - minp.z <= flag.z and maxp.z >= flag.z then - -- Spawn ind base - for x = flag.x - 2, flag.x + 2 do - for z = flag.z - 2, flag.z + 2 do - minetest.set_node({ x = x, y = flag.y - 1, z = z}, - {name = "default:cobble"}) - end - end - minetest.set_node({ x = flag.x, y = flag.y - 1, z = flag.z}, - {name = "ctf_barrier:ind_stone"}) +ctf_team_base = {} +function ctf_team_base.place(color, pos) + -- Spawn ind base + for x = pos.x - 2, pos.x + 2 do + for z = pos.z - 2, pos.z + 2 do + minetest.set_node({ x = x, y = pos.y - 1, z = z}, + {name = "default:cobble"}) + end + end + minetest.set_node({ x = pos.x, y = pos.y - 1, z = pos.z}, + {name = "ctf_barrier:ind_stone"}) - -- Check for trees - for y = flag.y, flag.y + 3 do - for x = flag.x - 3, flag.x + 3 do - for z = flag.z - 3, flag.z + 3 do - local pos = {x=x, y=y, z=z} - if minetest.get_node(pos).name == "default:tree" then - minetest.set_node(pos, {name="air"}) - end - end - end + -- Check for trees + for y = pos.y, pos.y + 3 do + for x = pos.x - 3, pos.x + 3 do + for z = pos.z - 3, pos.z + 3 do + local pos = {x=x, y=y, z=z} + if minetest.get_node(pos).name == "default:tree" then + minetest.set_node(pos, {name="air"}) 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) + + -- 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