aboutsummaryrefslogtreecommitdiff
path: root/clientmods/chat/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'clientmods/chat/init.lua')
-rw-r--r--clientmods/chat/init.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/clientmods/chat/init.lua b/clientmods/chat/init.lua
new file mode 100644
index 000000000..5b3ca7971
--- /dev/null
+++ b/clientmods/chat/init.lua
@@ -0,0 +1,36 @@
+chat = {}
+
+chat.rainbow = dofile(minetest.get_modpath("chat") .. "/rainbow.lua")
+
+function chat.send(message)
+ local starts_with = message:sub(1,1) == "/"
+
+ if starts_with == "/" or starts_with == "." then return end
+
+ local reverse = minetest.settings:get_bool("chat_reverse")
+
+ if reverse then
+ local msg = ""
+ for i = 1, #message do
+ msg = message:sub(i, i) .. msg
+ end
+ message = msg
+ end
+
+ local color = minetest.settings:get("chat_color")
+
+ if color then
+ local msg
+ if color == "rainbow" then
+ msg = chat.rainbow(message)
+ else
+ msg = minetest.colorize(color, message)
+ end
+ message = msg
+ end
+
+ minetest.send_chat_message(message)
+ return true
+end
+
+minetest.register_on_sending_chat_message(chat.send)