mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-25 14:03:43 +01:00
Fix "player still online" check of armor.unequip
(#146)
This commit is contained in:
parent
1fcbf64d53
commit
22955b413a
@ -719,13 +719,14 @@ armor.unequip = function(self, player, armor_element)
|
|||||||
if self:get_element(stack:get_name()) == armor_element then
|
if self:get_element(stack:get_name()) == armor_element then
|
||||||
armor_inv:set_stack("armor", i, "")
|
armor_inv:set_stack("armor", i, "")
|
||||||
minetest.after(0, function()
|
minetest.after(0, function()
|
||||||
-- resolve player object again in async function
|
local pplayer = minetest.get_player_by_name(name)
|
||||||
player = minetest.get_player_by_name(name)
|
if pplayer then -- player is still online
|
||||||
local inv = player:get_inventory()
|
local inv = pplayer:get_inventory()
|
||||||
if inv:room_for_item("main", stack) then
|
if inv:room_for_item("main", stack) then
|
||||||
inv:add_item("main", stack)
|
inv:add_item("main", stack)
|
||||||
else
|
else
|
||||||
minetest.add_item(player:get_pos(), stack)
|
minetest.add_item(pplayer:get_pos(), stack)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
self:run_callbacks("on_unequip", player, i, stack)
|
self:run_callbacks("on_unequip", player, i, stack)
|
||||||
|
Loading…
Reference in New Issue
Block a user