Compare commits

..

No commits in common. "aa12c0d2f7a796867fddf38e45c91e60dd9eeaf5" and "8ffdefa908aecffc4bab8795ec00daa2fec69ced" have entirely different histories.

8 changed files with 55 additions and 31 deletions

View File

@ -158,7 +158,6 @@ end
function ctf.reset()
ctf.log("io", "Deleting CTF save data...")
os.remove(minetest.get_worldpath().."/ctf.txt")
ctf.player_last_team = {}
ctf.init()
end

View File

@ -142,8 +142,6 @@ function ctf.register_on_join_team(func)
table.insert(ctf.registered_on_join_team, func)
end
ctf.player_last_team = {}
-- Player joins team
-- Called by /join, /team join or auto allocate.
function ctf.join(name, team, force, by)
@ -198,7 +196,6 @@ function ctf.join(name, team, force, by)
player.team = team
team_data.players[player.name] = player
ctf.player_last_team[name] = team
ctf.needs_save = true
@ -268,11 +265,6 @@ function ctf.autoalloc(name, alloc_mode)
if alloc_mode == 0 then
return
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 mtot = false -- more than one team

View File

@ -369,9 +369,7 @@ if minetest.global_exists("irc") then
color = ""
clear = ""
end
local abrace = color .. "<" .. clear
local bbrace = color .. ">" .. clear
return ("%s%s%s %s"):format(abrace, name, bbrace, message)
return ("%s%s%s <%s> %s"):format(color, tname, clear, name, message)
end
end

View File

@ -36,6 +36,11 @@ function ctf_colors.update(player, 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 tcolor_text == "red" or tcolor_text == "blue" then
print("tinting hud! " .. tcolor_hex)
@ -77,4 +82,21 @@ function ctf_colors.update(player, name, tplayer)
end
end
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]]

View File

@ -23,6 +23,8 @@ ctf.flag_colors = ctf_colors.colors
ctf.register_on_init(function()
ctf.log("colors", "Initialising...")
ctf._set("colors.skins", false)
ctf._set("colors.nametag", true)
ctf._set("colors.nametag.tcolor", false)
ctf._set("colors.hudtint", true)
ctf._set("hud.teamname", false)
end)

View File

@ -55,16 +55,16 @@ end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Todo: fix security issue here
-- local name = player:get_player_name()
-- if formname == "ctf:flags" then
-- for key, field in pairs(fields) do
-- local x,y,z = string.match(key, "goto_([%d-]+)_([%d-]+)_([%d-]+)")
-- if x and y and z then
-- player:setpos({ x=tonumber(x), y=tonumber(y), z=tonumber(z) })
-- return true
-- end
-- end
-- end
local name = player:get_player_name()
if formname == "ctf:flags" then
for key, field in pairs(fields) do
local x,y,z = string.match(key, "goto_([%d-]+)_([%d-]+)_([%d-]+)")
if x and y and z then
player:setpos({ x=tonumber(x), y=tonumber(y), z=tonumber(z) })
return true
end
end
end
end)
-- Flag interface

View File

@ -3,20 +3,13 @@ ctf.hud.register_part(function(player, name, tplayer)
if ctf.setting("flag.waypoints") then
for tname, team in pairs(ctf.teams) do
for _, flag in pairs(team.flags) do
local hud = "ctf:hud_" .. tname
local hud = "ctf:hud_" .. flag.x .. "_" .. flag.y .. "_" .. flag.z
local flag_name = flag.name or tname .. "'s base"
local color = ctf.flag_colors[team.data.color]
if not color then
color = "0x000000"
end
if ctf.hud:exists(player, hud) then
ctf.hud:change(player, hud, "world_pos", {
x = flag.x,
y = flag.y,
z = flag.z
})
else
if not ctf.hud:exists(player, hud) then
ctf.hud:add(player, hud, {
hud_elem_type = "waypoint",
name = flag_name,

View File

@ -114,6 +114,24 @@ ctf_flag.register_on_pick_up(function(attname, flag)
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
local pickup_times = {}
ctf_flag.register_on_pick_up(function(attname, flag)