From 7c071a45f5108f621d1822b23c0e6fa3a6725276 Mon Sep 17 00:00:00 2001 From: Zeg9 Date: Fri, 19 Apr 2013 21:07:02 +0200 Subject: [PATCH] Update to the "take items only if inventory is not full" behavior --- init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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,