diff options
author | rubenwardy <rubenwardy@gmail.com> | 2014-05-20 15:21:09 +0100 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-05-26 18:41:58 -0400 |
commit | 832d7973c8028d743eb331cb3d499692cebdc724 (patch) | |
tree | c7f8fd191e5d981b3fc71c7ee726fe86dc158854 /builtin/game/item.lua | |
parent | ab75b1b923db157a7d05c5498456a0fd1faee883 (diff) | |
download | hax-minetest-server-832d7973c8028d743eb331cb3d499692cebdc724.tar.gz hax-minetest-server-832d7973c8028d743eb331cb3d499692cebdc724.zip |
Add item eat callback
Diffstat (limited to 'builtin/game/item.lua')
-rw-r--r-- | builtin/game/item.lua | 6 |
1 files changed, 6 insertions, 0 deletions
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 |