Returning data out of an array using loop or for each?

0 favourites
  • 5 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello

    I'm here a again with a new question to search & use data from an array.

    If my array looks like this:

    y0 = 'Name1' 'Name2' 'Name3'

    y1= 'Interest1' 'Interest4' 'Interest2'

    y2= 'Interest2' 'Interest5' 'Interest5'

    y3= 'Interest3' 'Interest1' 'Interest6'

    It's easy to return every interest of a certain name in a text, but is there somebody who can help me with the code to return every name that has the same interest? For example 'Interest1' = 'Name1' & 'Name2'

    Thank in advance for every tip you can give me!

    Lennert

  • For "loopx" from 0 to array.width

    For "loopy" from 0 array.height

    Compare two values array.at(loopindex(loopx),loopindex(loopy) = 'interest1'

    Append TextObect: " " & array.at(loopindex(loopx),0)

  • A bg thank you for your interesting reply!

    But I don't understand 'loopy' or 'loopx'? Can I find those expressions anywhere? I do know 'loopindex' but nog loopy or loopx...

    -> correction: loopx and loopy are just the names you have given?

    thanks!

  • Correct, they are names in a "For" loop that allow you to specify which loopindex you are referring to in nested loops.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It worked!! Thank you so much!!

    And besides that, you finally made me understand the 'for' loop function!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)