summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPilzAdam <pilzadam@minetest.net>2013-05-03 15:37:04 -0700
committerPilzAdam <pilzadam@minetest.net>2013-05-03 15:37:04 -0700
commit7c7d3e2292f16b91dc8760e741cdd0988d8f5052 (patch)
tree84d1aaa1ac56b377e3b70afe2fa26fd9b9a49b58
parent913540214ce3f6dcda666cd2d16b24e710beda02 (diff)
parent7c071a45f5108f621d1822b23c0e6fa3a6725276 (diff)
Merge pull request #1 from Zeg9/master
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,