Builtin/../falling.lua: Avoid crash when object pos over limit
authorparamat <mat.gregory@virginmedia.com>
Wed, 21 Dec 2016 07:10:32 +0000 (07:10 +0000)
committerparamat <mat.gregory@virginmedia.com>
Wed, 21 Dec 2016 13:30:10 +0000 (13:30 +0000)
If the object pos is over limit, 'add entity' will not add an entity,
causing 'obj' to be nil.

builtin/game/falling.lua

index 8b88b68d83668d8a627f88ea38cde85bde148f08..4696ce4818ffd9e279ccc5d600f2efd8a48ca47c 100644 (file)
@@ -113,7 +113,9 @@ core.register_entity(":__builtin:falling_node", {
 
 local function spawn_falling_node(p, node)
        local obj = core.add_entity(p, "__builtin:falling_node")
-       obj:get_luaentity():set_node(node)
+       if obj then
+               obj:get_luaentity():set_node(node)
+       end
 end
 
 local function drop_attached_node(p)