Allow to config message duration

This commit is contained in:
Wuzzy 2016-11-04 04:06:22 +01:00
parent b0304e3493
commit 0149e3bb01
3 changed files with 23 additions and 6 deletions

View File

@ -27,6 +27,7 @@ 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 `0` for no limit. Default: `7`
* `central_message_time`: How long (in second) a message is shown. Default: `5`
* `central_message_color`: Set the message color of all messages. Value must be of format `(R,G,B)`. Default: `(255,255,255)` (white).

View File

@ -26,10 +26,22 @@ if setting then
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!")
minetest.log("warning", "[central_message] Invalid syntax of central_message_color setting!")
end
end
cmsg.settings.display_time = 5
local setting = minetest.setting_get("central_message_time")
if type(tonumber(setting)) == "number" then
if tonumber(setting) >= 1 then
cmsg.settings.display_time = tonumber(setting)
else
minetest.log("warning", "[central_message] Invalid value for central_message_time! Using default display time of 5 seconds.")
end
end
local function update_display(player, pname)
local messages = {}
local start, stop
@ -84,7 +96,7 @@ cmsg.push_message_player = function(player, text)
update_display(player, pname)
end
minetest.after(5, function(param)
minetest.after(cmsg.settings.display_time, function(param)
local pname = param.player:get_player_name()
for i=1, #cmsg.messages[pname] do
if param.msgid == cmsg.messages[pname][i].msgid then

View File

@ -1,5 +1,9 @@
#Maximum number of messages displayed at once. Use 0 for no limit.
central_message_max (Maximum message count) int 7 0
#Maximum number of messages in the center displayed at once.
#Use 0 for no limit.
central_message_max (Maximum number of central messages) int 7 0
#Message color of all messages (R,G,B).
central_message_color (Message color) string (255,255,255)
#How long (in seconds) a message in the center is shown.
central_message_time (Central message duration) int 5 1
#Message color of all messages shown in the center (R,G,B).
central_message_color (Central message color) string (255,255,255)