if enable_damage is false, disable eating functions

This commit is contained in:
tenplus1 2022-08-02 14:10:31 +01:00
parent 0fb4e82b58
commit 96570a558e

View File

@ -485,8 +485,12 @@ local function stamina_globaltimer(dtime)
end
-- override core.do_item_eat() so we can redirect hp_change to stamina
core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
-- stamina and eating functions disabled if damage is disabled
if minetest.settings:get_bool("enable_damage")
and minetest.settings:get_bool("enable_stamina") ~= false then
-- override core.do_item_eat() so we can redirect hp_change to stamina
core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
if user.is_fake_player then
return -- abort if called by fake player (eg. pipeworks-wielder)
@ -508,11 +512,10 @@ core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, point
end
return itemstack
end
end
-- not local since it's called from within core context
function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
-- not local since it's called from within core context
function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
if not itemstack or not user then
return itemstack
@ -606,12 +609,7 @@ function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thin
end
return itemstack
end
-- stamina is disabled if damage is disabled
if minetest.settings:get_bool("enable_damage")
and minetest.settings:get_bool("enable_stamina") ~= false then
end
minetest.register_on_joinplayer(function(player)