1
0
Fork 0

Add one food_tick_timer per player instead of using one for all players.

This commit is contained in:
Dieter44 2021-11-08 15:49:05 +01:00
parent 976f522b9d
commit 2f05388541
1 changed files with 9 additions and 3 deletions

View File

@ -137,12 +137,17 @@ 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)
local food_saturation_level = mcl_hunger.get_saturation(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)