From 962500b1894606c3654a044d6d648997bfc0877c Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 9 Mar 2022 02:23:18 +0100 Subject: [PATCH] Add check for unknown nodes. * Check if node has a definition table before attempting to evaluate its attributes. * Define local variable to cache multiple accesses to `registered_nodes[]` and improve readability. --- mods/ENTITIES/mobs_mc/slime+magma_cube.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 0c5fe24ac..8d855e761 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -16,7 +16,8 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance if not eject_speed then eject_speed = 1 end - local mother_stuck = minetest.registered_nodes[minetest.get_node(pos).name].walkable + local mndef = minetest.registered_nodes[minetest.get_node(pos).name] + local mother_stuck = mndef and mndef.walkable angle = math.random(0, math.pi*2) local children = {} for i=1,children_count do @@ -26,7 +27,8 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance -- If child would end up in a wall, use position of the "mother", unless -- the "mother" was stuck as well local speed_penalty = 1 - if (not mother_stuck) and minetest.registered_nodes[minetest.get_node(newpos).name].walkable then + local cndef = minetest.registered_nodes[minetest.get_node(newpos).name] + if (not mother_stuck) and cndef and cndef.walkable then newpos = pos speed_penalty = 0.5 end