summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2017-07-12 23:24:58 +0200
committerWuzzy <almikes@aol.com>2017-07-12 23:24:58 +0200
commitacac4fe33ff5a3ff4f2f9e45a67856f257c0cc5b (patch)
treed0c385346dadd4fbabeeeb8f1121aaaf60dd9516
parent3d7d613622cccecd2712251c758ed7bd10b734e4 (diff)
replace_with_item: Fix item disappear if inv full
-rw-r--r--hunger.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/hunger.lua b/hunger.lua
index dce52c0..effd25d 100644
--- a/hunger.lua
+++ b/hunger.lua
@@ -99,8 +99,16 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound
poisenp(1, poisen, 0, user)
end
- --sound:eat
- itemstack:add_item(replace_with_item)
+ if itemstack:get_count() == 0 then
+ itemstack:add_item(replace_with_item)
+ else
+ local inv = user:get_inventory()
+ if inv:room_for_item("main", replace_with_item) then
+ inv:add_item("main", replace_with_item)
+ else
+ minetest.add_item(user:getpos(), replace_with_item)
+ end
+ end
end
return itemstack
end