aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorCora de la Mouche <73539712+corarona@users.noreply.github.com>2023-11-04 02:06:28 +0100
committerGitHub <noreply@github.com>2023-11-04 02:06:28 +0100
commita2abd2dda025df43b7d7c54bed27700f5aad802c (patch)
treef0cc51b4aa9245ccc32baa4fd52ff67220f6f953 /init.lua
parent0c8c29a5cee69e7a58dfaf90194c31c9bf224724 (diff)
parentb6bb9bed92d2db20821247327e7c965cbf7b0365 (diff)
downloadautoeat-master.tar.xz
Merge pull request #2 from dragonfireclient/fix_startup_crashHEADmaster
Fix crash when localplayer isn't ready quickly enough
Diffstat (limited to 'init.lua')
-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")