aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2015-10-25 18:15:31 +0100
committerBlockMen <nmuelll@web.de>2015-10-25 18:15:31 +0100
commiteb92bfb03038aa2ed42af46ff5ec7d144f0ff9af (patch)
tree69222b5c5d1a634a48bce48091eb701d759bcc8b
parentdf2c474d19c751bb1ee25c0a11e52490b909c06b (diff)
downloadminetest-eb92bfb03038aa2ed42af46ff5ec7d144f0ff9af.tar.gz
minetest-eb92bfb03038aa2ed42af46ff5ec7d144f0ff9af.tar.bz2
minetest-eb92bfb03038aa2ed42af46ff5ec7d144f0ff9af.zip
Check if hitter has inventory when punching item
Fixes #3280
-rw-r--r--builtin/game/item_entity.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua
index 190473ceb..a8d7a1863 100644
--- a/builtin/game/item_entity.lua
+++ b/builtin/game/item_entity.lua
@@ -200,9 +200,10 @@ core.register_entity(":__builtin:item", {
end,
on_punch = function(self, hitter)
- if self.itemstring ~= '' then
- local left = hitter:get_inventory():add_item("main", self.itemstring)
- if not left:is_empty() then
+ local inv = hitter:get_inventory()
+ if inv and self.itemstring ~= '' then
+ local left = inv:add_item("main", self.itemstring)
+ if left and not left:is_empty() then
self.itemstring = left:to_string()
return
end