Add colored names to IRC
parent
2601a44b0e
commit
c56d3c84c1
|
@ -1,3 +1,4 @@
|
|||
ctf
|
||||
ctf_colors
|
||||
chatplus?
|
||||
irc?
|
||||
|
|
|
@ -370,6 +370,22 @@ if minetest.global_exists("chatplus") then
|
|||
minetest.chat_send_player(from, minetest.colorize("#" .. colorHex:sub(3, 8), "<" .. from .. "> ") .. msg)
|
||||
end
|
||||
|
||||
if minetest.global_exists("irc") then
|
||||
function irc.playerMessage(name, message)
|
||||
local color = ctf_colors.get_irc_color(name, ctf.player(name))
|
||||
local clear = "\x0F"
|
||||
print("color is " .. color)
|
||||
if color then
|
||||
color = "\x03" .. color
|
||||
else
|
||||
color = ""
|
||||
clear = ""
|
||||
end
|
||||
print("message: " .. ("%s<%s>%s %s"):format(color, name, clear, message))
|
||||
return ("%s<%s>%s %s"):format(color, name, clear, message)
|
||||
end
|
||||
end
|
||||
|
||||
chatplus.register_handler(function(from, to, msg)
|
||||
if not ctf.setting("chat.team_channel") then
|
||||
-- Send to global
|
||||
|
|
|
@ -12,6 +12,15 @@ function ctf_colors.get_color(name, tplayer)
|
|||
return tcolor_text, tcolor_hex
|
||||
end
|
||||
|
||||
function ctf_colors.get_irc_color(name, tplayer)
|
||||
local team = ctf.team(tplayer.team)
|
||||
local tcolor_text = nil
|
||||
if team then
|
||||
tcolor_text = team.data.color
|
||||
end
|
||||
return ctf_colors.irc_colors[tcolor_text]
|
||||
end
|
||||
|
||||
function ctf_colors.get_nametag_color(name, tplayer, tcolor_text, tcolor_hex)
|
||||
if ctf.setting("colors.nametag.tcolor") then
|
||||
return "0xFF" .. string.sub(tcolor_hex, 3)
|
||||
|
|
|
@ -14,6 +14,10 @@ ctf_colors.colors = {
|
|||
orange = "0xFFA500",
|
||||
gold = "0x808000"
|
||||
}
|
||||
ctf_colors.irc_colors = {
|
||||
red = "4",
|
||||
blue = "2",
|
||||
}
|
||||
ctf.flag_colors = ctf_colors.colors
|
||||
|
||||
ctf.register_on_init(function()
|
||||
|
|
Loading…
Reference in New Issue