mail/onjoin.lua

20 lines
435 B
Lua
Raw Normal View History

2018-12-05 11:06:25 +01:00
minetest.register_on_joinplayer(function(player)
minetest.after(2, function(name)
2019-02-27 08:20:09 +01:00
local messages = mail.getMessages(name)
2019-02-27 09:02:18 +01:00
local unreadcount = 0
2019-02-27 08:20:09 +01:00
2019-02-27 20:34:39 +01:00
for _, message in pairs(messages) do
2019-02-27 08:20:09 +01:00
if message.unread then
2019-02-27 09:02:18 +01:00
unreadcount = unreadcount + 1
2018-12-05 11:06:25 +01:00
end
end
2019-02-27 08:20:09 +01:00
2019-02-27 09:02:18 +01:00
if unreadcount > 0 then
minetest.chat_send_player(name,
2019-02-27 20:34:39 +01:00
"(" .. unreadcount .. ") You have mail! Type /mail to read")
2019-02-27 09:02:18 +01:00
2018-12-05 11:06:25 +01:00
end
2019-01-12 22:13:19 +00:00
end, player:get_player_name())
2019-01-12 21:59:54 +00:00
end)