From b4fbccd64ac758ee698f4f741250e9b682903363 Mon Sep 17 00:00:00 2001 From: Anand S Date: Sun, 9 Sep 2018 21:38:02 +0530 Subject: [PATCH] Add support for configurable coloring of IRC messages in-game IRC channel messages are colored green by default IRC PMs are colored purple by default --- botcmds.lua | 3 ++- config.lua | 5 +++-- messages.lua | 2 +- player_part.lua | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/botcmds.lua b/botcmds.lua index ba0d025..ec888ea 100644 --- a/botcmds.lua +++ b/botcmds.lua @@ -51,7 +51,8 @@ function irc.bot_command(msg, text) return end minetest.chat_send_player(player_to, - "PM from "..msg.user.nick.."@IRC: "..message, false) + minetest.colorize(irc.config.pm_color, + "PM from "..msg.user.nick.."@IRC: "..message, false)) irc.reply("Message sent!") return end diff --git a/config.lua b/config.lua index 10e5eb1..9a5c1fc 100644 --- a/config.lua +++ b/config.lua @@ -23,7 +23,7 @@ local function setting(stype, name, default, required) value = minetest.setting_get("irc."..name) elseif stype == "number" then value = tonumber(minetest.setting_get("irc."..name)) - end + end end if value == nil then if required then @@ -65,4 +65,5 @@ setting("bool", "debug", false) -- Enable debug output setting("bool", "enable_player_part", true) -- Whether to enable players joining and parting the channel setting("bool", "auto_join", true) -- Whether to automatically show players in the channel when they join setting("bool", "auto_connect", true) -- Whether to automatically connect to the server on mod load - +setting("string", "chat_color", "#339933") -- Color of IRC chat in-game, green by default +setting("string", "pm_color", "#8800AA") -- Color of IRC PMs in-game, purple by default diff --git a/messages.lua b/messages.lua index 83e4f7f..52b1d4c 100644 --- a/messages.lua +++ b/messages.lua @@ -8,7 +8,7 @@ function irc.logChat(message) end function irc.sendLocal(message) - minetest.chat_send_all(message) + minetest.chat_send_all(minetest.colorize(irc.config.chat_color, message)) irc.logChat(message) end diff --git a/player_part.lua b/player_part.lua index e703316..09aad75 100644 --- a/player_part.lua +++ b/player_part.lua @@ -63,7 +63,8 @@ end) function irc.sendLocal(message) for name, _ in pairs(irc.joined_players) do - minetest.chat_send_player(name, message) + minetest.chat_send_player(name, + minetest.colorize(irc.config.chat_color, message)) end irc.logChat(message) end