mirror of
https://github.com/mt-mods/mail.git
synced 2025-03-15 06:01:25 +00:00
Fix message notifications (#46)
* Fix mail notification on login * Fix HUD notification
This commit is contained in:
parent
3e3ea414ba
commit
56e86cd5e1
3 changed files with 6 additions and 2 deletions
3
api.lua
3
api.lua
|
@ -99,6 +99,9 @@ function mail.send(m)
|
|||
local name = player:get_player_name()
|
||||
if recipients[name] then
|
||||
minetest.chat_send_player(name, mail_alert)
|
||||
local receiver_entry = mail.get_storage_entry(name)
|
||||
local receiver_messages = receiver_entry.inbox
|
||||
mail.hud_update(name, receiver_messages)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
2
hud.lua
2
hud.lua
|
@ -43,7 +43,7 @@ function mail.hud_update(playername, messages)
|
|||
|
||||
local unreadcount = 0
|
||||
for _, message in ipairs(messages) do
|
||||
if message.unread then
|
||||
if not message.read then
|
||||
unreadcount = unreadcount + 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,11 +2,12 @@ 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 message.unread then
|
||||
if not message.read then
|
||||
unreadcount = unreadcount + 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue