# How do I pick a certain value from random Array position

Get help using Construct 2

### » Sat Oct 15, 2016 4:40 am

Hi everyone, how do you pick a random position in an array that contains certain value, and return the array x and y position.

For example

0 1 2 0 5 0
3 8 4 9 0 3

I want to choose a random array position that contains the value 0, which in this case will choose one of the following 0,0 3,0 5,0 4,1 and return the array position.

I tried but still can't seem to get the results I wanted for this. Would appreciate any help on this, thank you.
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

### » Sat Oct 15, 2016 7:57 am

B
67
S
24
G
7
Posts: 1,519
Reputation: 11,084

### » Sat Oct 15, 2016 2:10 pm

@korbaach. Thank you so much. This is exactly what I was looking for. Really appreciate it!
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

### » Sun Oct 16, 2016 2:47 pm

Imagine an array like the one below:

23....25....12....25....25....19....25
0.......1.......2......0......2......1......2

Select all y1 with value 2. Got three results. From those three results, choose a random y0 with value of 25, and return the x array value, which should return x4 or x6.

I really can't find a way to select one set of values from y1 array, than from those selection choose based on y0 values. Would really appreciate your help on this.
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

### » Sun Oct 16, 2016 3:38 pm

B
67
S
24
G
7
Posts: 1,519
Reputation: 11,084

### » Mon Oct 17, 2016 3:19 am

@korbaach, thank you very much! Perfect!
B
46
S
23
G
31
Posts: 693
Reputation: 20,637