Make global chat default, change style in chat log

This commit is contained in:
rubenwardy 2015-07-13 12:59:45 +01:00
parent 59946bc5a3
commit bd86f8bfef

View File

@ -1,9 +1,12 @@
function init() ctf_chat = {}
function ctf_chat.init()
-- Settings: Chat -- Settings: Chat
ctf._set("team_channel", true) ctf._set("chat.team_channel", true)
ctf._set("global_channel", true) ctf._set("chat.global_channel", true)
ctf._set("chat.default", "global")
end end
init() ctf_chat.init()
local function team_console_help(name) local function team_console_help(name)
minetest.chat_send_player(name,"Try:", false) minetest.chat_send_player(name,"Try:", false)
@ -185,24 +188,6 @@ minetest.register_chatcommand("team_owner", {
end, end,
}) })
minetest.register_chatcommand("all", {
params = "msg",
description = "Send a message on the global channel",
func = function(name, param)
if not ctf.setting("global_channel") then
minetest.chat_send_player(name,"The global channel is disabled",false)
return
end
if ctf.player(name) and ctf.player(name).team then
minetest.chat_send_all(ctf.player(name).team.." <"..name.."> "..param)
else
minetest.chat_send_all("GLOBAL <"..name.."> "..param)
end
end,
})
minetest.register_chatcommand("post", { minetest.register_chatcommand("post", {
params = "message", params = "message",
description = "Post a message on your team's message board", description = "Post a message on your team's message board",
@ -226,29 +211,77 @@ minetest.register_chatcommand("post", {
end, end,
}) })
minetest.register_chatcommand("all", {
params = "msg",
description = "Send a message on the global channel",
func = function(name, param)
if not ctf.setting("chat.global_channel") then
minetest.chat_send_player(name, "The global channel is disabled")
return
end
if ctf.player(name) and ctf.player(name).team then
minetest.chat_send_all(ctf.player(name).team .. " <" ..
name .. "> " .. param)
else
minetest.chat_send_all("<"..name.."> "..param)
end
end
})
minetest.register_chatcommand("t", {
params = "msg",
description = "Send a message on the team channel",
func = function(name, param)
if not ctf.setting("chat.team_channel") then
minetest.chat_send_player(name, "The team channel is disabled.")
return
end
if ctf.player(name).team then
local team = ctf.team(ctf.player(name).team)
if team then
for username, to in pairs(team.players) do
minetest.chat_send_player(username,
"<" .. name .. "> ** " .. param .. " **")
end
end
else
minetest.chat_send_player(name,
"You're not in a team, so you have no team to talk to.")
end
end
})
-- Chat plus stuff -- Chat plus stuff
if chatplus then if chatplus then
chatplus.register_handler(function(from,to,msg) chatplus.register_handler(function(from, to, msg)
if not ctf.setting("team_channel") then if not ctf.setting("chat.team_channel") or
ctf.setting("chat.default") ~= "team" then
-- Send to global
return nil return nil
end end
-- Send to team
local fromp = ctf.player(from) local fromp = ctf.player(from)
local top = ctf.player(to) local top = ctf.player(to)
if not fromp then if not fromp then
if not ctf.setting("global_channel") then if not ctf.setting("chat.global_channel") then
minetest.chat_send_player(from,"You are not yet part of a team, so you have no mates to send to",false) -- Send to global
return nil
else else
minetest.chat_send_player(to,"GLOBAL <"..from.."> "..msg,false) -- Global channel is disabled
minetest.chat_send_player(from,
"You are not yet part of a team! Join one so you can chat to people.",
false)
return false
end end
return false
end end
if not top then if top.team == fromp.team then
return false minetest.chat_send_player(to, "<" .. from .. "> ** " .. msg .. " **")
end end
return false
return (fromp.team == top.team)
end) end)
end end