Add success and output return values to chat commands
[oweals/minetest.git] / builtin / game / item.lua
index 8fd172aab6d8cbcc5a84bb27e2930dae1d411fcb..11a36bdc3e8653b0842315d5177910b92dcfd7c3 100644 (file)
@@ -353,6 +353,12 @@ end
 
 function core.item_eat(hp_change, replace_with_item)
        return function(itemstack, user, pointed_thing)  -- closure
+               for _, callback in pairs(core.registered_on_item_eats) do
+                       local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing)
+                       if result then
+                               return result
+                       end
+               end
                if itemstack:take_item() ~= nil then
                        user:set_hp(user:get_hp() + hp_change)
                        itemstack:add_item(replace_with_item) -- note: replace_with_item is optional