Add support for settingtypes.txt

This commit is contained in:
Wuzzy 2016-11-04 02:08:30 +01:00
parent 1a175c31ec
commit 2d62ac5b4e
3 changed files with 24 additions and 7 deletions

View File

@ -26,8 +26,8 @@ This mod can be configured via `minetest.conf`.
Currently, these settings are recognized:
* `central_message_max`: Limit the number of messages displayed at once, by providing a number. Use `inf` here for no limit. Default: 7
* `central_message_color`: Set the message color of all messages. Value must be `ColorString` (see `lua_api.txt`). Default: `0xFFFFFF` (white)
* `central_message_max`: Limit the number of messages displayed at once, by providing a number. Use 0here for no limit. Default: 7
* `central_message_color`: Set the message color of all messages. Value must be of format `(R,G,B)`. Default: `(255,255,255)` (white).
## API

View File

@ -7,15 +7,27 @@ cmsg.next_msgids = {}
cmsg.settings.max_messages = 7
local setting = minetest.setting_get("central_message_max")
if type(tonumber(setting)) == "number" then
cmsg.settings.max_messages = tonumber(setting)
elseif setting == "inf" then
if tonumber(setting) == 0 then
-- Infinite messages
cmsg.settings.max_messages = nil
else
cmsg.settings.max_messages = tonumber(setting)
end
end
cmsg.settings.color = 0xFFFFFF
setting = minetest.setting_get("central_message_color")
if type(tonumber(setting)) == "number" then
cmsg.settings.color = tonumber(setting)
if setting then
local r, g, b = string.match(setting, "%((%d+),(%d+),(%d+)%)")
r = tonumber(r)
g = tonumber(g)
b = tonumber(b)
if type(r) == "number" and type(g) == "number" and type(b) == "number" and
r >= 0 and r <= 255 and g >= 0 and g <= 255 and b >= 0 and b <= 255 then
cmsg.settings.color = r * 0x10000 + g * 0x100 + b
else
minetest.log("error", "[central_message] Invalid syntax of central_message_color setting!")
end
end
local function update_display(player, pname)

5
settingtypes.txt Normal file
View File

@ -0,0 +1,5 @@
#Maximum number of messages displayed at once. Use 0 for no limit.
central_message_max (Maximum message count) int 7 0
#Message color of all messages (R,G,B).
central_message_color (Message color) string (255,255,255)