1 Reply Latest reply on Jan 3, 2015 6:29 PM by johnrellis

    beginner question - how to efficiently check if a photo is part of the selection

    Haleakala Level 1

      Dear all,

       

      Sorry for this beginner question, however I don't know how to solve it and I'm sure that there is a quick and easy answer to this:

      My target is to get all the "heads of stack" (photos with Position 1 in stacks) of the selection ("photos" below).

       

      for i, photo in ipairs( photos ) do
        local photoName = photo:getFormattedMetadata('fileName')

       

         if photo:getRawMetadata( 'isInStackInFolder' ) then
         --Photo is in a stack
              local photoHeadOfStack = photo:getRawMetadata('topOfStackInFolderContainingPhoto')

              local stackPos = photo:getRawMetadata( 'stackPositionInFolder' ) -- get the position in the stack
              local photoHeadName = photoHeadOfStack:getFormattedMetadata('fileName')

              app:logVerbose("Photo nb ^1, name ^2 is in a stack with the position ^3", i, photoName, stackPos)

       

              if stackPos == 1 then
              -- photo is master of the stack
                   stackTop[#stackTop+1]=photo
                   app:logVerbose("Photo ^1 is top of the stack ^2", photoName, #stackTop)

                   -- check if couple if correct
              elseif photos.photoHeadOfStack then
                   app:logVerbose("Photo ^1 is in a stack, but not on top. Top of the stack already selected", photoName)

              else
                   stackTop[#stackTop+1]=photoHeadOfStack
                   app:logVerbose("Photo ^1 is in a stack, but not on top. Top of the stack ^2 - ^3 ", photoName, #stackTop, photoHeadName)

              end
        end
      end


      In the if structure in the middle checking the Position in the stack, if the Position is not 1, I would like to check if the photo heading the stack ('photoHeadOfStack') is part of 'photos'. I tried 'elseif photos.photoHeadOfStack then' and 'elseif photos[photoHeadOfStack] then' but it doesn't work ->this elseif is never true even if 'photoHeadOfStack' is part of 'photos'.

      Is there anyway to have this check done without checking "manually" photos ?(via for example a for Loop)

      I'm sure that Lua proposes this, but I don't know how...


      I thank you for your Support!