Bones: Return bones when taking the last ItemStack
authorSmallJoker <mk939@ymail.com>
Mon, 2 Oct 2017 09:01:01 +0000 (11:01 +0200)
committersfan5 <sfan5@live.de>
Sun, 19 Nov 2017 22:03:38 +0000 (23:03 +0100)
mods/bones/init.lua

index 9583bc29b20e6add2839537de20297d8ef84bbd9..8688fa1ef92dc3cf60aa1423de45e3b1697e4eb1 100644 (file)
@@ -68,6 +68,12 @@ minetest.register_node("bones:bones", {
        on_metadata_inventory_take = function(pos, listname, index, stack, player)
                local meta = minetest.get_meta(pos)
                if meta:get_inventory():is_empty("main") then
+                       local inv = player:get_inventory()
+                       if inv:room_for_item("main", {name = "bones:bones"}) then
+                               inv:add_item("main", {name = "bones:bones"})
+                       else
+                               minetest.add_item(pos, "bones:bones")
+                       end
                        minetest.remove_node(pos)
                end
        end,