From 808407f7c4a3c43401f5033b823b1452107c6b79 Mon Sep 17 00:00:00 2001 From: bakpakin Date: Tue, 5 May 2015 22:21:39 +0800 Subject: [PATCH] Fix 'tiny.add' and 'tiny.remove' iterating nil values. --- tiny.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tiny.lua b/tiny.lua index 6bac623..2708a23 100644 --- a/tiny.lua +++ b/tiny.lua @@ -391,10 +391,12 @@ function tiny.add(world, ...) local obj for i = 1, select("#", ...) do obj = select(i, ...) - if isSystem(obj) then - tiny_addSystem(world, obj) - else -- Assume obj is an Entity - tiny_addEntity(world, obj) + if obj then + if isSystem(obj) then + tiny_addSystem(world, obj) + else -- Assume obj is an Entity + tiny_addEntity(world, obj) + end end end end @@ -427,10 +429,12 @@ function tiny.remove(world, ...) local obj for i = 1, select("#", ...) do obj = select(i, ...) - if isSystem(obj) then - tiny_removeSystem(world, obj) - else -- Assume obj is an Entity - tiny_removeEntity(world, obj) + if obj then + if isSystem(obj) then + tiny_removeSystem(world, obj) + else -- Assume obj is an Entity + tiny_removeEntity(world, obj) + end end end end