From 832d7973c8028d743eb331cb3d499692cebdc724 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 20 May 2014 15:21:09 +0100 Subject: Add item eat callback --- builtin/game/item.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'builtin/game/item.lua') diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 8fd172aab..11a36bdc3 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -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 -- cgit v1.2.3