From 169d9e4359e09e931df514416d9ecacd1cdc11ea Mon Sep 17 00:00:00 2001 From: Timothy Date: Thu, 10 Jan 2019 16:13:36 -0600 Subject: [PATCH] Change getObjects method to filter by objType or name or by both The previous condition for the if loop ONLY worked if both the objType and name were BOTH present. If a user wanted to filter by just the objType or just the name, it was not possible. I've rewritten the code to allow this feature. --- ldurniat/berry.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ldurniat/berry.lua b/ldurniat/berry.lua index d4f9d9b..221096a 100644 --- a/ldurniat/berry.lua +++ b/ldurniat/berry.lua @@ -904,9 +904,18 @@ function M.new( filename, tilesetsDirectory ) object = layer[j] - if ( not name or object.name == name ) and ( not objType or object.type == objType ) then + if name and objType then -- must match both + if ( object.name == name ) and ( object.type == objType ) then + + objects[#objects + 1] = object + + end + else -- must match one + if ( object.name == name ) or ( object.type == objType ) then + + objects[#objects + 1] = object - objects[#objects + 1] = object + end end