Compare commits
5 Commits
8ffdefa908
...
aa12c0d2f7
Author | SHA1 | Date |
---|---|---|
|
aa12c0d2f7 | |
|
e2a59cef6e | |
|
87d0438db6 | |
|
8b12a8e4f1 | |
|
40c84728d4 |
|
@ -158,6 +158,7 @@ end
|
||||||
function ctf.reset()
|
function ctf.reset()
|
||||||
ctf.log("io", "Deleting CTF save data...")
|
ctf.log("io", "Deleting CTF save data...")
|
||||||
os.remove(minetest.get_worldpath().."/ctf.txt")
|
os.remove(minetest.get_worldpath().."/ctf.txt")
|
||||||
|
ctf.player_last_team = {}
|
||||||
ctf.init()
|
ctf.init()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,8 @@ function ctf.register_on_join_team(func)
|
||||||
table.insert(ctf.registered_on_join_team, func)
|
table.insert(ctf.registered_on_join_team, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ctf.player_last_team = {}
|
||||||
|
|
||||||
-- Player joins team
|
-- Player joins team
|
||||||
-- Called by /join, /team join or auto allocate.
|
-- Called by /join, /team join or auto allocate.
|
||||||
function ctf.join(name, team, force, by)
|
function ctf.join(name, team, force, by)
|
||||||
|
@ -196,6 +198,7 @@ function ctf.join(name, team, force, by)
|
||||||
|
|
||||||
player.team = team
|
player.team = team
|
||||||
team_data.players[player.name] = player
|
team_data.players[player.name] = player
|
||||||
|
ctf.player_last_team[name] = team
|
||||||
|
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
|
|
||||||
|
@ -265,6 +268,11 @@ function ctf.autoalloc(name, alloc_mode)
|
||||||
if alloc_mode == 0 then
|
if alloc_mode == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local last_team = ctf.player_last_team[name]
|
||||||
|
if last_team then
|
||||||
|
return last_team
|
||||||
|
end
|
||||||
|
|
||||||
local max_players = ctf.setting("maximum_in_team")
|
local max_players = ctf.setting("maximum_in_team")
|
||||||
|
|
||||||
local mtot = false -- more than one team
|
local mtot = false -- more than one team
|
||||||
|
|
|
@ -369,7 +369,9 @@ if minetest.global_exists("irc") then
|
||||||
color = ""
|
color = ""
|
||||||
clear = ""
|
clear = ""
|
||||||
end
|
end
|
||||||
return ("%s%s%s <%s> %s"):format(color, tname, clear, name, message)
|
local abrace = color .. "<" .. clear
|
||||||
|
local bbrace = color .. ">" .. clear
|
||||||
|
return ("%s%s%s %s"):format(abrace, name, bbrace, message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,6 @@ function ctf_colors.update(player, name, tplayer)
|
||||||
|
|
||||||
local tcolor_text, tcolor_hex = ctf_colors.get_color(name, tplayer)
|
local tcolor_text, tcolor_hex = ctf_colors.get_color(name, tplayer)
|
||||||
|
|
||||||
if ctf.setting("colors.nametag") then
|
|
||||||
player:set_nametag_attributes({
|
|
||||||
color = ctf_colors.get_nametag_color(name, tplayer, tcolor_text, tcolor_hex) })
|
|
||||||
end
|
|
||||||
|
|
||||||
if ctf.setting("colors.hudtint") then
|
if ctf.setting("colors.hudtint") then
|
||||||
if tcolor_text == "red" or tcolor_text == "blue" then
|
if tcolor_text == "red" or tcolor_text == "blue" then
|
||||||
print("tinting hud! " .. tcolor_hex)
|
print("tinting hud! " .. tcolor_hex)
|
||||||
|
@ -82,21 +77,4 @@ function ctf_colors.update(player, name, tplayer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
ctf.hud.register_part(ctf_colors.update)
|
ctf.hud.register_part(ctf_colors.update)
|
||||||
|
|
||||||
--[[if minetest.global_exists("armor") and armor.get_player_skin then
|
|
||||||
print("3d_armor detected!")
|
|
||||||
local old = armor.get_player_skin
|
|
||||||
function armor.get_player_skin(self, name)
|
|
||||||
local player = ctf.player(name)
|
|
||||||
local team = ctf.team(player.team)
|
|
||||||
if team and team.data.color and ctf.flag_colors[team.data.color] then
|
|
||||||
print("Return ctf_colors_skin_" .. team.data.color .. ".png")
|
|
||||||
return "ctf_colors_skin_" .. team.data.color .. ".png"
|
|
||||||
end
|
|
||||||
print("ctf_colors -!- Reverting to default armor skin")
|
|
||||||
|
|
||||||
return old(self, name)
|
|
||||||
end
|
|
||||||
end]]
|
|
||||||
|
|
|
@ -23,8 +23,6 @@ ctf.flag_colors = ctf_colors.colors
|
||||||
ctf.register_on_init(function()
|
ctf.register_on_init(function()
|
||||||
ctf.log("colors", "Initialising...")
|
ctf.log("colors", "Initialising...")
|
||||||
ctf._set("colors.skins", false)
|
ctf._set("colors.skins", false)
|
||||||
ctf._set("colors.nametag", true)
|
|
||||||
ctf._set("colors.nametag.tcolor", false)
|
|
||||||
ctf._set("colors.hudtint", true)
|
ctf._set("colors.hudtint", true)
|
||||||
ctf._set("hud.teamname", false)
|
ctf._set("hud.teamname", false)
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -55,16 +55,16 @@ end)
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
-- Todo: fix security issue here
|
-- Todo: fix security issue here
|
||||||
local name = player:get_player_name()
|
-- local name = player:get_player_name()
|
||||||
if formname == "ctf:flags" then
|
-- if formname == "ctf:flags" then
|
||||||
for key, field in pairs(fields) do
|
-- for key, field in pairs(fields) do
|
||||||
local x,y,z = string.match(key, "goto_([%d-]+)_([%d-]+)_([%d-]+)")
|
-- local x,y,z = string.match(key, "goto_([%d-]+)_([%d-]+)_([%d-]+)")
|
||||||
if x and y and z then
|
-- if x and y and z then
|
||||||
player:setpos({ x=tonumber(x), y=tonumber(y), z=tonumber(z) })
|
-- player:setpos({ x=tonumber(x), y=tonumber(y), z=tonumber(z) })
|
||||||
return true
|
-- return true
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Flag interface
|
-- Flag interface
|
||||||
|
|
|
@ -3,13 +3,20 @@ ctf.hud.register_part(function(player, name, tplayer)
|
||||||
if ctf.setting("flag.waypoints") then
|
if ctf.setting("flag.waypoints") then
|
||||||
for tname, team in pairs(ctf.teams) do
|
for tname, team in pairs(ctf.teams) do
|
||||||
for _, flag in pairs(team.flags) do
|
for _, flag in pairs(team.flags) do
|
||||||
local hud = "ctf:hud_" .. flag.x .. "_" .. flag.y .. "_" .. flag.z
|
local hud = "ctf:hud_" .. tname
|
||||||
local flag_name = flag.name or tname .. "'s base"
|
local flag_name = flag.name or tname .. "'s base"
|
||||||
local color = ctf.flag_colors[team.data.color]
|
local color = ctf.flag_colors[team.data.color]
|
||||||
if not color then
|
if not color then
|
||||||
color = "0x000000"
|
color = "0x000000"
|
||||||
end
|
end
|
||||||
if not ctf.hud:exists(player, hud) then
|
|
||||||
|
if ctf.hud:exists(player, hud) then
|
||||||
|
ctf.hud:change(player, hud, "world_pos", {
|
||||||
|
x = flag.x,
|
||||||
|
y = flag.y,
|
||||||
|
z = flag.z
|
||||||
|
})
|
||||||
|
else
|
||||||
ctf.hud:add(player, hud, {
|
ctf.hud:add(player, hud, {
|
||||||
hud_elem_type = "waypoint",
|
hud_elem_type = "waypoint",
|
||||||
name = flag_name,
|
name = flag_name,
|
||||||
|
|
|
@ -114,24 +114,6 @@ ctf_flag.register_on_pick_up(function(attname, flag)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Change nametag color
|
|
||||||
local oldntc = ctf_colors.get_nametag_color
|
|
||||||
function ctf_colors.get_nametag_color(name, tplayer, tcolor_text, tcolor_hex)
|
|
||||||
if ctf_flag.get_claimed_by_player(name) then
|
|
||||||
return "0xFFFF0000"
|
|
||||||
else
|
|
||||||
return oldntc(name, tplayer, tcolor_text, tcolor_hex)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ctf_flag.register_on_pick_up(function(attname, flag)
|
|
||||||
ctf_colors.update(nil, attname, ctf.player(attname))
|
|
||||||
end)
|
|
||||||
|
|
||||||
ctf_flag.register_on_drop(function(attname, flag)
|
|
||||||
ctf_colors.update(nil, attname, ctf.player(attname))
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Drop after time
|
-- Drop after time
|
||||||
local pickup_times = {}
|
local pickup_times = {}
|
||||||
ctf_flag.register_on_pick_up(function(attname, flag)
|
ctf_flag.register_on_pick_up(function(attname, flag)
|
||||||
|
|
Loading…
Reference in New Issue