Flag no build area
This commit is contained in:
parent
685cd18ecd
commit
0a4f30df25
@ -6,16 +6,23 @@ ctf.register_on_init(function()
|
|||||||
ctf._set("flag.names", true)
|
ctf._set("flag.names", true)
|
||||||
ctf._set("flag.waypoints", true)
|
ctf._set("flag.waypoints", true)
|
||||||
ctf._set("flag.protect_distance", 25)
|
ctf._set("flag.protect_distance", 25)
|
||||||
|
ctf._set("flag.nobuild_radius", 3)
|
||||||
ctf._set("flag.capture_mode", "take")
|
ctf._set("flag.capture_mode", "take")
|
||||||
ctf._set("gui.team.teleport_to_flag", true)
|
ctf._set("gui.team.teleport_to_flag", true)
|
||||||
ctf._set("gui.team.teleport_to_spawn", false)
|
ctf._set("gui.team.teleport_to_spawn", false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("ctf_flag") .. "/hud.lua")
|
||||||
|
dofile(minetest.get_modpath("ctf_flag") .. "/gui.lua")
|
||||||
|
dofile(minetest.get_modpath("ctf_flag") .. "/flag_func.lua")
|
||||||
|
dofile(minetest.get_modpath("ctf_flag") .. "/api.lua")
|
||||||
|
dofile(minetest.get_modpath("ctf_flag") .. "/flags.lua")
|
||||||
|
|
||||||
ctf.register_on_new_team(function(team)
|
ctf.register_on_new_team(function(team)
|
||||||
team.flags = {}
|
team.flags = {}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf.register_on_territory_query(function(pos)
|
function ctf_flag.get_nearest(pos)
|
||||||
local closest = nil
|
local closest = nil
|
||||||
local closest_team = nil
|
local closest_team = nil
|
||||||
local closest_distSQ = 1000000
|
local closest_distSQ = 1000000
|
||||||
@ -34,7 +41,9 @@ ctf.register_on_territory_query(function(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return closest_team, closest_distSQ
|
return closest_team, closest_distSQ
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
ctf.register_on_territory_query(ctf_flag.get_nearest)
|
||||||
|
|
||||||
function ctf.get_spawn(team)
|
function ctf.get_spawn(team)
|
||||||
if not ctf.team(team) then
|
if not ctf.team(team) then
|
||||||
@ -54,8 +63,21 @@ function ctf.get_spawn(team)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/hud.lua")
|
-- Add minimum build range
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/gui.lua")
|
local old_is_protected = minetest.is_protected
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/flag_func.lua")
|
local r = ctf.setting("flag.nobuild_radius")
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/api.lua")
|
local rs = r * r
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/flags.lua")
|
function minetest.is_protected(pos, name)
|
||||||
|
if rs == 0 then
|
||||||
|
return old_is_protected(pos, name)
|
||||||
|
end
|
||||||
|
|
||||||
|
local tname, distsq = ctf_flag.get_nearest(pos)
|
||||||
|
if distsq < rs then
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
"Too close to the flag! You need to be at least " .. r .. " nodes away.")
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return old_is_protected(pos, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user