title: Lua for loop does not iterate properly
body: <p>I am in dire need of help with a for loop. I'm trying to go through a for loop in Lua with the Corona SDK, but I am doing something wrong but I don't know what. See below for my code:</p>
  
  <pre><code>function moveLift(event)
      for j=1,4,1 do
          if event.phase == "began" then
              markY = event.target.y
  
          elseif event.phase == "moved" then
              local y = (event.y - event.yStart) + markY
              event.target.y = y
  
          elseif event.phase == "ended" then
  
              if (hasCollided( event.target, hotSpots[j] )) then
  
                  print("hasCollided with floor: ", hotSpots[j].floor)
  
                  if (event.target.destination == hotSpots[j].floor) then
                      print("correct floor")
                      succesfullPassengers = succesfullPassengers + 1
  
                      if succesfullPassengers == PASSENGER_AMOUNT then
                          print("game over")
                      end
                  else
                      print("Wrong! elevator has collided with floor: ", hotSpots[j].floor)
                  end
              end
          end
          return true
      end
  end
  </code></pre>
  
  <p>What I'm trying to do here is checking when I drag and drop an elevator on screen on what floor it has landed. I've created hotspots (basically hitboxes and currently serving as art placeholder) and placed them in the hotSpot table like this:</p>
  
  <pre><code>-- Create elevator hotspots
  for k=1,4,1 do
      hotSpots[k] = display.newRect( gameAreaGroup, 0, 0, 50, 75 )
      hotSpots[k].alpha = 0.25  --Show hotspots with alpha
      hotSpots[k].floor = k -- The floor id
      print("Created hotspot on floor: ",hotSpots[k].floor)
      hotSpots[k].x = display.contentWidth *0.5
      hotSpots[k].y = firstFloor - (FLOOR_HEIGHT * k)
      hotSpots[k]:setFillColor( 255,0,0 )
      hotSpots[k]:addEventListener( "tap", returnFloor ) -- Check floor value
      gameAreaGroup:insert(hotSpots[k])
  end
  </code></pre>
  
  <p>I check if every hotspot has a unique floor value with a test function called returnFloor, which they have (1,2,3,4). When I drag and drop my elevator on the first floor, I receive the message "Wrong! elevator has collided with floor: 1", but on any other floor I receive the message: "hasCollided with floor: 1". So there must be something wrong with the for loop in my moveLift function because it only returns floor 1 and not any other floor.</p>
  
  <p>PS: the correct floor is 4, the top floor.</p>