Drop nodes as items when dugged and no room in inventory and dont remove dropped...
authorPilzAdam <PilzAdam@gmx.de>
Sat, 12 Jan 2013 19:18:43 +0000 (20:18 +0100)
committerPilzAdam <PilzAdam@gmx.de>
Thu, 21 Feb 2013 15:58:50 +0000 (16:58 +0100)
builtin/item.lua
builtin/item_entity.lua

index 69c4bd0bbde7b4246d43b1a49d43c41ee02ed78e..1349fdf63834d133bbb0cf46a5ce22c5a1cc8065 100644 (file)
@@ -290,7 +290,15 @@ function minetest.handle_node_drops(pos, drops, digger)
        if digger:get_inventory() then
                local _, dropped_item
                for _, dropped_item in ipairs(drops) do
-                       digger:get_inventory():add_item("main", dropped_item)
+                       local left = digger:get_inventory():add_item("main", dropped_item)
+                       if not left:is_empty() then
+                               local p = {
+                                       x = pos.x + math.random()/2-0.25,
+                                       y = pos.y + math.random()/2-0.25,
+                                       z = pos.z + math.random()/2-0.25,
+                               }
+                               minetest.env:add_item(p, left)
+                       end
                end
        end
 end
index 46415e53854fa08199ab1ac5bfb8ced3dd57b548..1699cb03c0c49d590b516c8ca20a84af9d9e8b1a 100644 (file)
@@ -109,7 +109,10 @@ minetest.register_entity("__builtin:item", {
 
        on_punch = function(self, hitter)
                if self.itemstring ~= '' then
-                       hitter:get_inventory():add_item("main", self.itemstring)
+                       local left = hitter:get_inventory():add_item("main", self.itemstring)
+                       if not left:is_empty() then
+                               return
+                       end
                end
                self.object:remove()
        end,