{"action":"created","issue":{"url":"https://api.github.com/repos/BlockMen/hud/issues/14","labels_url":"https://api.github.com/repos/BlockMen/hud/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/BlockMen/hud/issues/14/comments","events_url":"https://api.github.com/repos/BlockMen/hud/issues/14/events","html_url":"https://github.com/BlockMen/hud/issues/14","id":57373759,"number":14,"title":"Eating from stack removes all with replace_with_item","user":{"login":"tenplus1","id":8145060,"avatar_url":"https://avatars.githubusercontent.com/u/8145060?v=3","gravatar_id":"","url":"https://api.github.com/users/tenplus1","html_url":"https://github.com/tenplus1","followers_url":"https://api.github.com/users/tenplus1/followers","following_url":"https://api.github.com/users/tenplus1/following{/other_user}","gists_url":"https://api.github.com/users/tenplus1/gists{/gist_id}","starred_url":"https://api.github.com/users/tenplus1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tenplus1/subscriptions","organizations_url":"https://api.github.com/users/tenplus1/orgs","repos_url":"https://api.github.com/users/tenplus1/repos","events_url":"https://api.github.com/users/tenplus1/events{/privacy}","received_events_url":"https://api.github.com/users/tenplus1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BlockMen/hud/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-02-11T20:38:28Z","updated_at":"2015-03-01T17:01:58Z","closed_at":null,"body":"Eating from a stack of mushroom soup or hearty stew replaces the whole stack with a single bowl which isnt too good, so I've redone the routine within hunger.lua to add the replace_with_item to the inventory if space is available or drop as an item if not...\r\n\r\n```\r\nfunction hud.item_eat(hunger_change, replace_with_item, poisen, heal)\r\n\treturn function(itemstack, user, pointed_thing)\r\n\t\r\n\t\tif itemstack:take_item() ~= nil and user ~= nil then\r\n\t\t\r\n\t\t\tlocal name = user:get_player_name()\r\n\t\t\tlocal h = tonumber(hud.hunger[name])\r\n\t\t\tlocal hp = user:get_hp()\r\n\t\t\tlocal rm = false\r\n\t\t\tlocal msg = nil\r\n\r\n\t\t\t-- Healing\r\n\t\t\tif hp < 20 and heal then\r\n\t\t\t\thp = hp + heal\r\n\t\t\t\tif hp > 20 then hp = 20 end\r\n\t\t\t\tuser:set_hp(hp)\r\n\t\t\t\trm = true\r\n\t\t\t\tmsg = \"\"\r\n\t\t\telseif hp == 20 and heal then\r\n\t\t\t\tmsg = \"You already have full health\"\r\n\t\t\tend\r\n\r\n\t\t\t-- Hunger\r\n\t\t\tif h < 30 and hunger_change then\r\n\t\t\t\th = h + hunger_change\r\n\t\t\t\tif h > 30 then h = 30 end\r\n\t\t\t\thud.hunger[name]=h\r\n\t\t\t\thud.set_hunger(user)\r\n\t\t\t\trm = true\r\n\t\t\telseif h>= 30 and hunger_change and not msg then\r\n\t\t\t\tmsg = \"Cannot eat, not hungry\"\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tif msg then minetest.chat_send_player(user:get_player_name(), msg) end\r\n\t\t\t\r\n\t\t\t-- Poison\r\n\t\t\tif poisen then\r\n\t\t\t\tpoisenp(1.0, poisen, 0, user)\r\n\t\t\tend\r\n\r\n\t\t\t-- if item eaten and replace_with_item, check if inventory full, add/drop replacement\r\n\t\t\tif rm then\r\n\t\t\t\tlocal inv = user:get_inventory()\r\n\t\t\t\tif inv:room_for_item(\"main\", {name=replace_with_item}) then\r\n\t\t\t\t\tinv:add_item(\"main\", replace_with_item)\r\n\t\t\t\telse\r\n\t\t\t\t\tlocal pos = user:getpos()\r\n\t\t\t\t\tpos.y = math.floor(pos.y + 0.5)\r\n\t\t\t\t\tcore.add_item(pos, replace_with_item)\r\n\t\t\t\tend\r\n\r\n\t\t\t\treturn itemstack\r\n\t\t\tend\r\n\t\t\t\r\n\t\tend\r\n\tend\r\nend"},"comment":{"url":"https://api.github.com/repos/BlockMen/hud/issues/comments/76613185","html_url":"https://github.com/BlockMen/hud/issues/14#issuecomment-76613185","issue_url":"https://api.github.com/repos/BlockMen/hud/issues/14","id":76613185,"user":{"login":"MT-Modder","id":7414772,"avatar_url":"https://avatars.githubusercontent.com/u/7414772?v=3","gravatar_id":"","url":"https://api.github.com/users/MT-Modder","html_url":"https://github.com/MT-Modder","followers_url":"https://api.github.com/users/MT-Modder/followers","following_url":"https://api.github.com/users/MT-Modder/following{/other_user}","gists_url":"https://api.github.com/users/MT-Modder/gists{/gist_id}","starred_url":"https://api.github.com/users/MT-Modder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MT-Modder/subscriptions","organizations_url":"https://api.github.com/users/MT-Modder/orgs","repos_url":"https://api.github.com/users/MT-Modder/repos","events_url":"https://api.github.com/users/MT-Modder/events{/privacy}","received_events_url":"https://api.github.com/users/MT-Modder/received_events","type":"User","site_admin":false},"created_at":"2015-03-01T17:01:58Z","updated_at":"2015-03-01T17:01:58Z","body":"Oh..."}}