--- /dev/null
+MIT License
+
+Copyright (c) 2018
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
--- /dev/null
+# Colored Names
+
+## Description
+
+![Screenshot](https://raw.githubusercontent.com/SmallJoker/colored_names/master/screenshot.png)
+
+This client mod colorizes the nicknames in-game, so communicating gets easier, even when many people are chatting with each other. On some servers with special chat mods, this mod will stay inactive until it detects a raw/unmodified chat line.
+
+License: MIT
+
+## Installation
+1. Close all Minetest processes
+2. Join the Minetest directory which contains the directories `mods`, `games`, ...
+3. (Create and) open the directory `clientmods` in this location
+4. `git clone https://github.com/SmallJoker/colored_names.git`
+5. (Create and) open the file `mods.conf` in `clientmods`
+6. Add or update the line `load_mod_colored_names = true`
+7. Start Minetest
--- /dev/null
+-- Backwards compatibility for 0.4.x
+if not core.register_on_receiving_chat_message then
+ core.register_on_receiving_chat_message = core.register_on_receiving_chat_messages
+end
+
+local color_reset = "\x1b(c@#FFF)"
+local c_pattern = "\x1b%(c@#[0-9a-fA-F]+%)"
+
+core.register_on_receiving_chat_message(function(line)
+ local myname_l = "~[CAPSĀ£"
+ if core.localplayer then
+ myname_l = core.localplayer:get_name():lower()
+ end
+
+ -- Detect color to still do the name mentioning effect
+ local color, line_nc = line:match("^(" .. c_pattern .. ")(.*)")
+ line = line_nc or line
+
+ local prefix
+ local chat_line = false
+
+ local name, color_end, message = line:match("^%<(%S+)%>%s*(" .. c_pattern .. ")%s*(.*)")
+ if not message then
+ name, message = line:match("^%<(%S+)%> (.*)")
+ if name then
+ name = name:gsub(c_pattern, "")
+ end
+ end
+
+ if message then
+ -- To keep the <Name> notation
+ chat_line = true
+ else
+ -- Server messages, actions
+ prefix, name, message = line:match("^(%*+ )(%S+) (.*)")
+ end
+ if not message then
+ -- Colored prefix
+ prefix, name, message = line:match("^(.* )%<(%S+)%> (.*)")
+ if color and message and prefix:len() > 0 then
+ prefix = color .. prefix .. color_reset
+ color = nil
+ end
+ chat_line = true
+ end
+ if not message then
+ -- Skip unknown chat line
+ return
+ end
+
+ prefix = prefix or ""
+ local name_wrap = name
+
+ -- No color yet? We need color.
+ if not color then
+ local color = core.sha1(name, true)
+ local R = color:byte( 1) % 0x10
+ local G = color:byte(10) % 0x10
+ local B = color:byte(20) % 0x10
+ if R + G + B < 24 then
+ R = 15 - R
+ G = 15 - G
+ B = 15 - B
+ end
+ if chat_line then
+ name_wrap = "<" .. name .. ">"
+ end
+ name_wrap = minetest.colorize(string.format("#%X%X%X", R, G, B), name_wrap)
+ elseif chat_line then
+ name_wrap = "<" .. name .. ">"
+ end
+
+ if (chat_line or prefix == "* ") and name:lower() ~= myname_l
+ and message:lower():find(myname_l) then
+ prefix = minetest.colorize("#F33", "[!] ") .. prefix
+ end
+
+ return minetest.display_chat_message(prefix .. (color or "")
+ .. name_wrap .. (color_end or "") .. " " .. message)
+end)
\ No newline at end of file
dofile(path.."/waila.lua")
dofile(path.."/music_handling.lua")
dofile(path.."/version_send.lua")
+ dofile(path.."/colored_names/colored_names.lua")
end
--we must delay initialization until the player exists in the world
minetest.after(0,function()
- version_channel:send_all("0.5001")
+ version_channel:send_all("0.5002")
end)
\ No newline at end of file