1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-22 07:38:48 -05:00

Drop nodes as items when dugged and no room in inventory and dont remove dropped items when no room in inventory

This commit is contained in:
PilzAdam 2013-01-12 20:18:43 +01:00
parent b29834ab02
commit ef6b8bee07
2 changed files with 13 additions and 2 deletions

View 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

View 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,