How do I look up information in arrays?

Just started using Construct 2? Post your questions here

Post » Sat Sep 20, 2014 4:12 am

Hi there. I'm still newish to Construct 2, and trying to figure out how I can look up values is stored in arrays that correspond to a key value.

For example, if I've given a sprite an instance variable set to "30", and I want to look up "30" in column 1 of my array, then read the column 5 value of that same row... how could I approach this?

(Ultimately, what I want to do is go through all the sprites of a kind, look each up in array containing various attributes, and determine which one has the highest number in a certain column. Any push in the right direction would be appreciated greatly, though.)

Thanks in advance to anyone who can help.
Posts: 5
Reputation: 177

Post » Sat Sep 20, 2014 4:25 am

This can be done with one of the most useful array expression combo:"30"), 4)

However, indexOf only works to search value in the 0th column only. You have to be careful and consistent in using array when storing numbers or strings.
Posts: 553
Reputation: 4,924

Post » Sun Sep 21, 2014 3:35 pm

In addition to the above, I highly recommend you take a look at the Arrays for Beginners tutorial. It covers everything you should need to know about inserting data, retrieving data, and other uses for arrays.
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
Posts: 255
Reputation: 2,008

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests