mail/attachment.lua

25 lines
583 B
Lua
Raw Normal View History

2019-02-27 10:33:49 +01:00
local invmap = {}
mail.getAttachmentInventory = function(playername)
return invmap[playername]
end
mail.getAttachmentInventoryName = function(playername)
return "mail:" .. name
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
minetest.remove_detached_inventory(mail.getAttachmentInventoryName(name))
end)