diff options
author | Cora de la Mouche <73539712+corarona@users.noreply.github.com> | 2023-11-04 02:06:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-04 02:06:28 +0100 |
commit | a2abd2dda025df43b7d7c54bed27700f5aad802c (patch) | |
tree | f0cc51b4aa9245ccc32baa4fd52ff67220f6f953 /init.lua | |
parent | 0c8c29a5cee69e7a58dfaf90194c31c9bf224724 (diff) | |
parent | b6bb9bed92d2db20821247327e7c965cbf7b0365 (diff) | |
download | autoeat-master.tar.xz |
Fix crash when localplayer isn't ready quickly enough
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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") |