summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeg9 <dazeg9@gmail.com>2013-04-19 21:07:02 +0200
committerZeg9 <dazeg9@gmail.com>2013-04-19 21:07:02 +0200
commit7c071a45f5108f621d1822b23c0e6fa3a6725276 (patch)
tree84d1aaa1ac56b377e3b70afe2fa26fd9b9a49b58
parent913540214ce3f6dcda666cd2d16b24e710beda02 (diff)
Update to the "take items only if inventory is not full" behavior
-rw-r--r--init.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 14f2288..21801ca 100644
--- a/init.lua
+++ b/init.lua
@@ -171,7 +171,11 @@ 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
+ self.itemstring = left:to_string()
+ return
+ end
end
self.object:remove()
end,