How do I pick a certain value from random Array position

Get help using Construct 2

Post » 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
45
S
23
G
31
Posts: 691
Reputation: 20,608

Post » Sat Oct 15, 2016 7:57 am

Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Sat Oct 15, 2016 2:10 pm

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

Post » Sun Oct 16, 2016 2:47 pm

@korbaach, could you please help me with another array problem I am having.

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
45
S
23
G
31
Posts: 691
Reputation: 20,608

Post » Sun Oct 16, 2016 3:38 pm

Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Mon Oct 17, 2016 3:19 am

@korbaach, thank you very much! Perfect!
B
45
S
23
G
31
Posts: 691
Reputation: 20,608


Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 63 guests