From 4962b31bcc285d2266fe9fdceaa130eb2bcdfedb Mon Sep 17 00:00:00 2001 From: Nomad Senaxsys Date: Sat, 28 Sep 2024 22:24:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- onjoin.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 onjoin.lua diff --git a/onjoin.lua b/onjoin.lua new file mode 100644 index 0000000..ef602e5 --- /dev/null +++ b/onjoin.lua @@ -0,0 +1,23 @@ +-- translation +local S = mail.S + +minetest.register_on_joinplayer(function(player) + minetest.after(2, function(name) + local entry = mail.get_storage_entry(name) + local messages = entry.inbox + mail.hud_update(name, messages) + + local unreadcount = 0 + + for _, message in pairs(messages) do + if not message.read then + unreadcount = unreadcount + 1 + end + end + + if unreadcount > 0 and mail.get_setting(name, "onjoin_notifications") then + minetest.chat_send_player(name, + minetest.colorize(mail.get_color("new"), "(" .. unreadcount .. ") " .. S("You have mail! Type /mail to read"))) + end + end, player:get_player_name()) +end)