From 2f053885414d0cc5d480e92d2acc63e7e7de8b1a Mon Sep 17 00:00:00 2001 From: Dieter44 <55900078+Dieter44@users.noreply.github.com> Date: Mon, 8 Nov 2021 15:49:05 +0100 Subject: [PATCH] Add one food_tick_timer per player instead of using one for all players. --- mods/PLAYER/mcl_hunger/init.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index 0405c28ef0..1e3d07a479 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -137,11 +137,16 @@ end) -local food_tick_timer = 0 +local food_tick_timers = {} --one food_tick_timer per player, keys are the player-objects minetest.register_globalstep(function(dtime) - food_tick_timer = food_tick_timer + dtime - for _,player in ipairs(minetest.get_connected_players()) do + + local food_tick_timer = food_tick_timers[player] + if food_tick_timer == nil then + food_tick_timer = 0 + else + food_tick_timer = food_tick_timer + dtime + end local player_name = player:get_player_name() local food_level = mcl_hunger.get_hunger(player) @@ -172,6 +177,7 @@ minetest.register_globalstep(function(dtime) mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player)) end + food_tick_timers[player] = food_tick_timer --update food_tick_timer table end end)