No announcement yet.

Question about Looping

  • Filter
  • Time
  • Show
Clear All
new posts

    Question about Looping

    k, I watched a tutorial about inventory item stacking.
    The tutor is trying to stack items that are the same into an inventory slot.
    He combines loop with loop. But wouldn't that mean he has the same element of an array twice???

    Click image for larger version

Name:	_N$A[N8{5Q7K(3TP2@{]6{G.jpg
Views:	1
Size:	106.4 KB
ID:	1221935
    I dont know exactly how this works bc I am no expert, but to me it looks like loop 1 gets all elements of the array, and loop 2 gets the same elements, so that would mean
    he wouldn instead of just looking which elements have the same name also compar Element 1 with itself, and element 2 with itself, etc.
    Just looks weird, maybe it works different,
    someone pls enlighten me


    Your second loop has no array connected to it so it has no array to iterate through.

    Generally, if you have 2 different arrays in a nested loop, you can check each element of your first array against each element of the second array.


      it was a mistake in the video, he took 2 loops connecting to the same array variable, later he corrected it.
      So it's fine now.