onjoin.lua 523 B

12345678910111213141516171819202122
  1. minetest.register_on_joinplayer(function(player)
  2. minetest.after(2, function(name)
  3. local messages = mail.getMessages(name)
  4. local unreadcount = 0
  5. for _, message in pairs(messages) do
  6. if message.unread then
  7. unreadcount = unreadcount + 1
  8. end
  9. end
  10. if unreadcount > 0 then
  11. minetest.chat_send_player(name,
  12. minetest.colorize("#00f529", "(" .. unreadcount .. ") You have mail! Find a mailbox to read it."))
  13. end
  14. end, player:get_player_name())
  15. mail.migrate_contacts(player:get_player_name())
  16. end)