aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorTriBlade9 <triblade9@mail.com>2015-01-16 14:54:26 +0800
committerEkdohibs <nathanael.courant@laposte.net>2016-05-31 17:34:29 +0200
commit1d40385d4aacf0cbea4b19ff06940e8c9bebaf47 (patch)
tree39732d23598a1c14d514ff35d241f9499f0a3c13 /builtin
parent0e44af9f7056a78a8e561f708751acceacd149c1 (diff)
downloadminetest-1d40385d4aacf0cbea4b19ff06940e8c9bebaf47.tar.gz
minetest-1d40385d4aacf0cbea4b19ff06940e8c9bebaf47.tar.bz2
minetest-1d40385d4aacf0cbea4b19ff06940e8c9bebaf47.zip
Colored chat working as expected for both freetype and non-freetype builds. @nerzhul improvements * Add unit tests * Fix coding style * move guiChatConsole.hpp to client/
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/chatcommands.lua2
-rw-r--r--builtin/game/misc.lua17
2 files changed, 18 insertions, 1 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index 3350140ee..2627559a5 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -102,7 +102,7 @@ core.register_chatcommand("help", {
description = "Get help for commands or list privileges",
func = function(name, param)
local function format_help_line(cmd, def)
- local msg = "/"..cmd
+ local msg = core.colorize("00ffff", "/"..cmd)
if def.params and def.params ~= "" then
msg = msg .. " " .. def.params
end
diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua
index de41cfc91..8d5c80216 100644
--- a/builtin/game/misc.lua
+++ b/builtin/game/misc.lua
@@ -197,3 +197,20 @@ function core.http_add_fetch(httpenv)
return httpenv
end
+
+function core.get_color_escape_sequence(color)
+ --if string.len(color) == 3 then
+ -- local r = string.sub(color, 1, 1)
+ -- local g = string.sub(color, 2, 2)
+ -- local b = string.sub(color, 3, 3)
+ -- color = r .. r .. g .. g .. b .. b
+ --end
+
+ --assert(#color == 6, "Color must be six characters in length.")
+ --return "\v" .. color
+ return "\v(color;" .. color .. ")"
+end
+
+function core.colorize(color, message)
+ return core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("ffffff")
+end