Skip to content

Commit

Permalink
Change getObjects method to filter by objType or name or by both
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timothymtorres committed Jan 10, 2019
1 parent b17c034 commit 169d9e4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ldurniat/berry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 169d9e4

Please sign in to comment.