From 500a3ccd584ba153d269be7a1b6529652880f02b Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 3 Jan 2024 21:19:04 -0800 Subject: [PATCH] Fix very rare crash --- mods/apis/hud_events/init.lua | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/mods/apis/hud_events/init.lua b/mods/apis/hud_events/init.lua index 53eee7061f..e505591556 100644 --- a/mods/apis/hud_events/init.lua +++ b/mods/apis/hud_events/init.lua @@ -82,16 +82,24 @@ local function handle_hud_events(player) end hud_queues[pname].t = minetest.after(HUD_SHOW_TIME, function() - hud:change(player, "hud_event", {text = ""}) - - hud_queues[pname].t = minetest.after(HUD_SHOW_NEXT_TIME, function() - if #hud_queues[pname].e >= 1 then - handle_hud_events(player) - else - hud:remove(player, "hud_event") - hud_queues[pname] = nil - end - end) + player = minetest.get_player_by_name(pname) + + if player then + hud:change(player, "hud_event", {text = ""}) + + hud_queues[pname].t = minetest.after(HUD_SHOW_NEXT_TIME, function() + player = minetest.get_player_by_name(pname) + + if player then + if #hud_queues[pname].e >= 1 then + handle_hud_events(player) + else + hud:remove(player, "hud_event") + hud_queues[pname] = nil + end + end + end) + end end) end