Stop flags disappearing on map reset
This commit is contained in:
parent
8444c36f3f
commit
ca9699d3eb
@ -182,6 +182,9 @@ minetest.after(0, function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function ctf.check_save()
|
function ctf.check_save()
|
||||||
|
if ctf_flag and ctf_flag.assert_flags then
|
||||||
|
ctf_flag.assert_flags()
|
||||||
|
end
|
||||||
if ctf.needs_save then
|
if ctf.needs_save then
|
||||||
ctf.save()
|
ctf.save()
|
||||||
end
|
end
|
||||||
|
@ -115,10 +115,14 @@ minetest.register_chatcommand("ctf_clean", {
|
|||||||
description = "Do admin cleaning stuff",
|
description = "Do admin cleaning stuff",
|
||||||
privs = {ctf_admin=true},
|
privs = {ctf_admin=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
ctf.log("chat", "Cleaning CTF...")
|
||||||
ctf.clean_player_lists()
|
ctf.clean_player_lists()
|
||||||
if ctf_flag.collect_claimed then
|
if ctf_flag and ctf_flag.collect_claimed then
|
||||||
ctf_flag.collect_claimed()
|
ctf_flag.collect_claimed()
|
||||||
end
|
end
|
||||||
|
if ctf_flag and ctf_flag.assert_flags then
|
||||||
|
ctf_flag.assert_flags()
|
||||||
|
end
|
||||||
minetest.chat_send_player(name, "CTF cleaned!")
|
minetest.chat_send_player(name, "CTF cleaned!")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -43,7 +43,7 @@ function ctf.get_spawn(team)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Get spawn from first flag
|
-- Get spawn from first flag
|
||||||
ctf_flag.asset_flags(team)
|
ctf_flag.assert_flags(team)
|
||||||
if #ctf.team(team).flags > 0 then
|
if #ctf.team(team).flags > 0 then
|
||||||
return ctf.team(team).flags[1]
|
return ctf.team(team).flags[1]
|
||||||
else
|
else
|
||||||
@ -154,22 +154,30 @@ function ctf_flag.delete(team, pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ctf_flag.asset_flags(team)
|
function ctf_flag.assert_flags()
|
||||||
--[[
|
ctf.log("flag", "Checking flags...")
|
||||||
if not team or not ctf.team(team) then
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
ctf.log("utils", "Checking the flags of "..team)
|
ctf.log("flag", " - of "..tname)
|
||||||
|
|
||||||
local tmp = ctf.team(team).flags
|
for i=1, #team.flags do
|
||||||
local get_res = minetest.env:get_node(tmp[i])
|
local flag = team.flags[i]
|
||||||
for i=1,#tmp do
|
minetest.get_voxel_manip(flag, { x = flag.x + 1, y = flag.y + 1, z = flag.z + 1})
|
||||||
if tmp[i] and (not get_res or not get_res.name == "ctf:flag") then
|
local nodename = minetest.get_node(flag).name
|
||||||
ctf.log("utils", "Replacing flag...")
|
if nodename ~= "ctf_flag:flag" then
|
||||||
-- TODO: ctf_flag.asset_flags
|
ctf.log("flag", " - found " .. nodename .. ", correcting...")
|
||||||
|
minetest.set_node(flag, { name = "ctf_flag:flag"})
|
||||||
end
|
end
|
||||||
end]]--
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The flag
|
-- The flag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user