mail/attachment.lua

28 lines
640 B
Lua
Raw Normal View History

2019-09-16 09:06:54 +03:00
local invmap = {}
mail.getAttachmentInventory = function(playername)
return invmap[playername]
end
mail.getAttachmentInventoryName = function(playername)
return "mail:" .. playername
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
local inv = minetest.create_detached_inventory(mail.getAttachmentInventoryName(name), {})
invmap[name] = inv
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
invmap[name] = nil
if minetest.remove_detached_inventory then
minetest.remove_detached_inventory(mail.getAttachmentInventoryName(name))
end
end)