aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcora <coradelamouche@gmx.ch>2023-09-03 05:38:58 +0200
committercora <coradelamouche@gmx.ch>2023-09-03 05:38:58 +0200
commitb6bb9bed92d2db20821247327e7c965cbf7b0365 (patch)
treef0cc51b4aa9245ccc32baa4fd52ff67220f6f953
parent0c8c29a5cee69e7a58dfaf90194c31c9bf224724 (diff)
downloadautoeat-b6bb9bed92d2db20821247327e7c965cbf7b0365.tar.xz
Fix crash when localplayer isn't ready quickly enoughfix_startup_crash
-rw-r--r--init.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/init.lua b/init.lua
index 6233b4c..bc020df 100644
--- a/init.lua
+++ b/init.lua
@@ -58,17 +58,20 @@ minetest.register_globalstep(function(dtime)
end
end)
-minetest.after(3, function()
+local function find_hud()
local player = minetest.localplayer
+ if not player then minetest.after(3,find_hud) end
local def
local i = -1
repeat
i = i + 1
- def = player:hud_get(i)
+ def = player and player:hud_get(i)
until not def or def.text == "hbhunger_icon.png"
if def then
hud_id = i
end
-end)
+end
+
+minetest.after(3, find_hud)
minetest.register_cheat("AutoEat", "Player", "autoeat")