From 0174b486f206efcaa574e93756132c033f74147d Mon Sep 17 00:00:00 2001 From: luk3yx Date: Mon, 30 Aug 2021 08:57:32 +1200 Subject: [PATCH] Fix hunger crash --- builtin/game/hunger.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/game/hunger.lua b/builtin/game/hunger.lua index d4bc7b394..99f9ee908 100644 --- a/builtin/game/hunger.lua +++ b/builtin/game/hunger.lua @@ -138,8 +138,9 @@ function hunger.set_poisoned(player, poisoned) player:get_meta():set_string(attribute.poisoned, attr) end -local function poison_tick(player, ticks, interval, elapsed) - if not hunger.is_poisoned(player) then +local function poison_tick(name, ticks, interval, elapsed) + local player = minetest.get_player_by_name(name) + if not player or not hunger.is_poisoned(player) then return elseif elapsed > ticks then hunger.set_poisoned(player, false) @@ -148,7 +149,7 @@ local function poison_tick(player, ticks, interval, elapsed) if hp > 0 then player:set_hp(hp) end - core.after(interval, poison_tick, player, ticks, interval, elapsed + 1) + core.after(interval, poison_tick, name, ticks, interval, elapsed + 1) end end @@ -169,7 +170,7 @@ function hunger.poison(player, ticks, interval) return end hunger.set_poisoned(player, true) - poison_tick(player, ticks, interval, 0) + poison_tick(player:get_player_name(), ticks, interval, 0) end --- END POISON API ---