Fix crash when colorizing chat
This commit is contained in:
parent
07c31c7f48
commit
d4d82674e1
@ -6,7 +6,7 @@ Advanced Ranks [ranks]
|
||||
- Download: https://github.com/octacian/ranks/archive/master.zip
|
||||
- Forum: https://forum.minetest.net/viewtopic.php?f=9&t=17640
|
||||
|
||||
**Warning:** Ranks uses important features currently only available in development builds of Minetest. In order to use Ranks, you'll need to [build](https://forum.minetest.net/viewtopic.php?id=3837) Minetest yourself with [this commit](https://github.com/minetest/minetest/pull/5716) or newer (May 7th, 2016).
|
||||
**Notice:** Your experience with Ranks can be improved by using a development build of Minetest. In order to use Ranks at its full potential, you'll need to [build](https://forum.minetest.net/viewtopic.php?id=3837) Minetest yourself with [this commit](https://github.com/minetest/minetest/commit/bc53c82bcf923d11725e3de8565eb4c7e435cd2b) or newer (June 21st, 2017).
|
||||
|
||||
Ranks is an advanced ranks mod geared towards larger servers helps to both distiguish between players and make managing privileges much easier. With several ranks premade and a simplistic API, ranks is a good addition to any server, especially those with many players.
|
||||
|
||||
@ -49,4 +49,4 @@ If name is blank, your own rank is returned
|
||||
### Creating Ranks
|
||||
You can create your own ranks and learn about privilege management in the API documentation. It explains how to manage privileges and register ranks with the `ranks.register` function. Registrations can be made either in the `ranks.lua` file of the mod itself (where default ranks or unregistered), or they can be preferrably placed in a `ranks.lua` file inside the world directory.
|
||||
|
||||
If you don't want one of the built in ranks, you can either register a new rank with the same name (effectively overriding the rank) or learn about `ranks.unregister` which can also be called from the world file.
|
||||
If you don't want one of the built in ranks, you can either register a new rank with the same name (effectively overriding the rank) or learn about `ranks.unregister` which can also be called from the world file.
|
||||
|
9
init.lua
9
init.lua
@ -236,6 +236,15 @@ minetest.register_on_chat_message(function(name, message)
|
||||
local def = ranks.get_def(rank)
|
||||
if def.prefix then
|
||||
local colour = def.colour or "#ffffff"
|
||||
if type(colour) == "table" then
|
||||
if minetest.rgba then
|
||||
colour = minetest.rgba(colour.r, colour.g, colour.b, colour.a)
|
||||
else
|
||||
minetest.chat_send_all(def.prefix.." <"..name.."> "..message)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
minetest.chat_send_all(minetest.colorize(colour, def.prefix)..
|
||||
" <"..name.."> "..message)
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user