mail/onjoin.lua
Peter Nerlich f82c3d2b82 add contacts dir, leave mail files as is
- restructured storage.lua so reading/writing json is not duplicated
- when a player joins and has no contacts file yet, automatically add all players he wrote to
2020-08-10 18:29:11 +02:00

22 lines
485 B
Lua

minetest.register_on_joinplayer(function(player)
minetest.after(2, function(name)
local messages = mail.getMessages(name)
local unreadcount = 0
for _, message in pairs(messages) do
if message.unread then
unreadcount = unreadcount + 1
end
end
if unreadcount > 0 then
minetest.chat_send_player(name,
"(" .. unreadcount .. ") You have mail! Type /mail to read")
end
end, player:get_player_name())
mail.migrate_contacts(player:get_player_name())
end)