mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-26 09:59:33 +01:00
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.
This commit is contained in:
parent
95cfa43483
commit
962500b189
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue