From: PilzAdam Date: Sat, 12 Jan 2013 19:18:43 +0000 (+0100) Subject: Drop nodes as items when dugged and no room in inventory and dont remove dropped... X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=ef6b8bee07b9cefe7d463fabd199548d37ff2bee;p=zefram%2Fminetest%2Fminetest_engine.git Drop nodes as items when dugged and no room in inventory and dont remove dropped items when no room in inventory --- diff --git a/builtin/item.lua b/builtin/item.lua index 69c4bd0b..1349fdf6 100644 --- a/builtin/item.lua +++ b/builtin/item.lua @@ -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 diff --git a/builtin/item_entity.lua b/builtin/item_entity.lua index 46415e53..1699cb03 100644 --- a/builtin/item_entity.lua +++ b/builtin/item_entity.lua @@ -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,