Add ctf_flag.assert_flag()
This commit is contained in:
parent
0a4f30df25
commit
a914b43439
@ -168,24 +168,11 @@ function ctf_flag.delete(team, pos)
|
||||
end
|
||||
end
|
||||
|
||||
function ctf_flag.assert_flags()
|
||||
for tname, team in pairs(ctf.teams) do
|
||||
ctf_flag.assert_flags_team(tname)
|
||||
end
|
||||
end
|
||||
|
||||
function ctf_flag.assert_flags_team(tname)
|
||||
local team = ctf.team(tname)
|
||||
if not tname or not team then
|
||||
return false
|
||||
end
|
||||
|
||||
for i=1, #team.flags do
|
||||
local flag = team.flags[i]
|
||||
function ctf_flag.assert_flag(flag)
|
||||
minetest.get_voxel_manip(flag, { x = flag.x + 1, y = flag.y + 1, z = flag.z + 1})
|
||||
local nodename = minetest.get_node(flag).name
|
||||
if nodename ~= "ctf_flag:flag" then
|
||||
ctf.log("flag", tname .. " has wrong node at flag position, " .. nodename .. ", correcting...")
|
||||
ctf.log("flag", flag.team .. " has wrong node at flag position, " .. nodename .. ", correcting...")
|
||||
minetest.set_node(flag, { name = "ctf_flag:flag"})
|
||||
|
||||
local function base_at(flag, dx, dz)
|
||||
@ -204,6 +191,26 @@ function ctf_flag.assert_flags_team(tname)
|
||||
base_at(flag, 1, -1)
|
||||
base_at(flag, 1, 0)
|
||||
base_at(flag, 1, 1)
|
||||
|
||||
if minetest.get_node(flag).name ~= "ctf_flag:flag" then
|
||||
ctf_flag.update(flag)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ctf_flag.assert_flags()
|
||||
for tname, team in pairs(ctf.teams) do
|
||||
ctf_flag.assert_flags_team(tname)
|
||||
end
|
||||
end
|
||||
|
||||
function ctf_flag.assert_flags_team(tname)
|
||||
local team = ctf.team(tname)
|
||||
if not tname or not team then
|
||||
return false
|
||||
end
|
||||
|
||||
for i=1, #team.flags do
|
||||
ctf_flag.assert_flag(team.flags[i])
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user