You would use the object your actually controlling. If that object was type x, you would do the for each on the type y.
-+ for each type y set position to type x(loopindex).x, type x(loopindex).y
Without using the index you could assign a variable a value like:
-+system on start of layout
->for n =1 to 100
-->system create object type x
--->type x set variable to loopindex("n")
-->system create object type y
--->type y set variable to loopindex("n")
Then use the variable comparison, as I suggested before.
A loop, or a for each should be used here as well.
Btw type x, and type y... probably not the best naming method. :P