From 1521c1006e5e2cf5271e4e2f14bf837b2c769d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Van=C4=9Bk?= Date: Tue, 4 Aug 2020 20:21:21 +0200 Subject: [PATCH] fix: do not crash when looking at unknown nodes "Unknown nodes" have real IDs, but they do not have corresponding registered node. This makes Minetest crash due to nil dereference in the describe_node() function. --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 75138c1..6e87e3c 100644 --- a/init.lua +++ b/init.lua @@ -20,7 +20,7 @@ minetest.register_globalstep(function(dtime) -- This will run every tick, so aro update_player_hud_pos(player, player_to_animtime[player]) end - if lookat then + if lookat and minetest.registered_nodes[lookat.name] ~= nil then if player_to_cnode[player] ~= lookat.name then -- Only do anything if they are looking at a different type of block than before player_to_animtime[player] = nil -- Reset the animation local nodename, mod = describe_node(lookat) -- Get the details of the block in a nice looking way