How do I search a particular range of an array?

Just started using Construct 2? Post your questions here

Post » Wed Nov 25, 2015 7:45 pm

With arrays there just seems to be 'for each element' as a way of searching through.

It seems inefficient and awkward that if I had an array with 100 value and I just want to search from 12 to 18, I have to set it to go through the whole thing and set up some way of counting when I'm actually inside the range I want.

If I wanted to search from position 12 (or whatever number inside the array size) through a bunch of strings in the array until I find "<NP>", is there another way to do this apart from 'for each element'? It's for showing the instructions of the game, with <NP> signifying the end of one page of text.
B
51
S
14
G
4
Posts: 191
Reputation: 5,537

Post » Wed Nov 25, 2015 8:20 pm

I have an alternative that might work for you. Let's take your example and say you want to search from position 12 to 18 until you find <NP>:

Image
Remember you can right click the image and click 'view image' if it doesn't fit your screen.
Image
B
12
S
4
G
1
Posts: 30
Reputation: 946

Post » Sun Dec 06, 2015 4:21 am

Thank you, Voulk. I think that will do it!
B
51
S
14
G
4
Posts: 191
Reputation: 5,537


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests