diff options
author | cheapie <no-email-for-you@example.com> | 2017-03-27 13:49:42 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2017-03-27 13:49:42 -0500 |
commit | 9abe5998c3ea013f71d1c9c2c4cd2692029e5139 (patch) | |
tree | 3ec7dbb9022fb48d4f50c224c5dd040aeecd5119 | |
parent | 235b2edb589ee9969338160ce4981b953cb8cf5d (diff) | |
download | chat6-9abe5998c3ea013f71d1c9c2c4cd2692029e5139.tar chat6-9abe5998c3ea013f71d1c9c2c4cd2692029e5139.tar.gz chat6-9abe5998c3ea013f71d1c9c2c4cd2692029e5139.tar.bz2 chat6-9abe5998c3ea013f71d1c9c2c4cd2692029e5139.tar.xz chat6-9abe5998c3ea013f71d1c9c2c4cd2692029e5139.zip |
Add timestamp support
-rw-r--r-- | init.lua | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -2,6 +2,7 @@ local player_name = "cheapie" local highlight_color = "#4E9A06" local send_nick_color = "#A40000" local send_message_color = "#888A85" +local timestamps = true local nick_colors = { "#4E9A06", --19 @@ -30,6 +31,11 @@ minetest.register_on_receiving_chat_messages(function(message) local msgtype local user local text + local timestamp = "" + if timestamps then + local date = os.date("*t",os.time()) + timestamp = string.format("[%02d:%02d:%02d] ",date.hour,date.min,date.sec) + end if string.sub(message,1,1) == "<" then msgtype = "channel" user,text = string.match(message,"^<(%g*)> (.*)$") @@ -64,31 +70,31 @@ minetest.register_on_receiving_chat_messages(function(message) text = message end if msgtype == "special" then - minetest.display_chat_message(text) + minetest.display_chat_message(timestamp..text) elseif msgtype == "joined" then local coloredmsg = minetest.colorize("#CE5C00",string.format("* %s has joined",user)) - minetest.display_chat_message(coloredmsg) + minetest.display_chat_message(timestamp..coloredmsg) elseif msgtype == "left" then local coloredmsg = minetest.colorize("#C4A000",string.format("* %s has quit %s",user,text)) - minetest.display_chat_message(coloredmsg) + minetest.display_chat_message(timestamp..coloredmsg) elseif msgtype == "channel" then local colorednick = minetest.colorize(get_nick_color(user),user) - minetest.display_chat_message(string.format("<%s> %s",colorednick,text)) + minetest.display_chat_message(timestamp..string.format("<%s> %s",colorednick,text)) elseif msgtype == "action" then local colorednick = minetest.colorize(get_nick_color(user),user) - minetest.display_chat_message(string.format("* %s %s",colorednick,text)) + minetest.display_chat_message(timestamp..string.format("* %s %s",colorednick,text)) elseif msgtype == "sent_channel" then local colorednick = minetest.colorize(send_nick_color,user) local coloredtext = minetest.colorize(send_message_color,text) - minetest.display_chat_message(string.format("<%s> %s",colorednick,coloredtext)) + minetest.display_chat_message(timestamp..string.format("<%s> %s",colorednick,coloredtext)) elseif msgtype == "sent_action" then local colorednick = minetest.colorize(send_nick_color,user) local coloredtext = minetest.colorize(send_message_color,text) - minetest.display_chat_message(string.format("* %s %s",colorednick,coloredtext)) + minetest.display_chat_message(timestamp..string.format("* %s %s",colorednick,coloredtext)) elseif msgtype == "highlight_channel" then - minetest.display_chat_message(minetest.colorize(highlight_color,string.format("<%s> %s",user,text))) + minetest.display_chat_message(timestamp..minetest.colorize(highlight_color,string.format("<%s> %s",user,text))) elseif msgtype == "highlight_action" then - minetest.display_chat_message(minetest.colorize(highlight_color,string.format("* %s %s",user,text))) + minetest.display_chat_message(timestamp..minetest.colorize(highlight_color,string.format("* %s %s",user,text))) end return true end) |