From 9f1acb4eaaf6e5afbe8a343cd842e874d7b3fcf7 Mon Sep 17 00:00:00 2001 From: fluxionary <25628292+fluxionary@users.noreply.github.com> Date: Thu, 18 May 2023 05:14:36 -0700 Subject: [PATCH] Behavior tweaks when eating "empty" food (#46) - Allow eating food which doesn't restore saturation when the player is full - Don't apply poison effect when eating food that isn't actually poisonous --- init.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 7ba8c5f..318e01c 100644 --- a/init.lua +++ b/init.lua @@ -480,8 +480,8 @@ function minetest.do_item_eat(hp_change, replace_with_item, itemstack, player, p end local level = stamina.get_saturation(player) or 0 - if level >= settings.visual_max then - -- don't eat if player is full + if level >= settings.visual_max and hp_change > 0 then + -- don't eat if player is full and item provides saturation return itemstack end @@ -498,8 +498,7 @@ function minetest.do_item_eat(hp_change, replace_with_item, itemstack, player, p if hp_change > 0 then stamina.change_saturation(player, hp_change) stamina.set_exhaustion(player, 0) - else - -- assume hp_change < 0. + elseif hp_change < 0 then stamina.poison(player, -hp_change, settings.poison_tick) end