add sfinv_buttons compatibility

This commit is contained in:
aBlueShadow 2024-01-08 22:48:17 +01:00 committed by Athozus
parent 3eafeb4cf8
commit 94f37da092
4 changed files with 15 additions and 5 deletions

View File

@ -13,7 +13,7 @@ read_globals = {
"dump",
-- Deps
"unified_inventory", "default",
"unified_inventory", "default", "sfinv_buttons",
-- optional mods
"mtt", "canonical_name"

View File

@ -94,14 +94,14 @@ function mail.send(m)
-- notify recipients that happen to be online
local mail_alert = S("You have a new message from @1! Subject: @2", m.from, m.subject) ..
"\n" .. S("To view it, type /mail")
local unified_inventory_alert = S("You could also use the button in your inventory.")
local inventory_alert = S("You could also use the button in your inventory.")
for _, player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if recipients[name] then
if mail.get_setting(name, "chat_notifications") == true then
minetest.chat_send_player(name, mail_alert)
if minetest.get_modpath("unified_inventory") then
minetest.chat_send_player(name, unified_inventory_alert)
if minetest.get_modpath("unified_inventory") or minetest.get_modpath("sfinv_buttons") then
minetest.chat_send_player(name, inventory_alert)
end
end
if mail.get_setting(name, "sound_notifications") == true then

10
gui.lua
View File

@ -10,3 +10,13 @@ if minetest.get_modpath("unified_inventory") then
end
})
end
if minetest.get_modpath("sfinv_buttons") then
sfinv_buttons.register_button("mail", {
title = "Mail",
image = "mail_button.png",
action = function(player)
mail.show_mail_menu(player:get_player_name())
end
})
end

View File

@ -1,3 +1,3 @@
name = mail
description = ingame mail-system
optional_depends = canonical_name,default,mtt,unified_inventory
optional_depends = canonical_name,default,mtt,unified_inventory,sfinv_buttons