How do I For Each (Predefined number list)?

Get help using Construct 2

Post » Thu Jun 16, 2016 8:21 am

I've seen a post about "For Each (random)" before.
But what if you would like to do a For Each on a given number list (that has no pattern).
E.g.
For Each [1,4,12,15]?

So that first loop would run events for #1.. next for #4, next #12 and so on.. in that order.

Hm.. I got a feeling I may have just answered my question while writing this. But it seems like it would have to involve doing something with a for each from 1 to 4, and then calling in a function passing the numbers one-by-one as parameters. Any thoughts/tips/ideas/advice? Perhaps a more straight forward approach? Thanks!
B
15
S
7
G
34
Posts: 55
Reputation: 18,478

Post » Thu Jun 16, 2016 4:31 pm

Have an array and fill it with your numbers, then each loop just pull out a number from your array like: Array.At(random(Array.Width-1))
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Thu Jun 16, 2016 5:33 pm

gumshoe2029 wrote:Have an array and fill it with your numbers, then each loop just pull out a number from your array like: Array.At(random(Array.Width-1))


Hi @gumshoe2029!
I suppose an array would do the trick. Thanks! :)
B
15
S
7
G
34
Posts: 55
Reputation: 18,478

Post » Fri Jun 17, 2016 5:08 pm

If you need it to be non-repeating, then remove that entry after you select it.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830


Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, dop2000, PROxMTswatTR and 25 guests