Loop until find an object with value.

Get help using Construct 2

Post » Mon Mar 04, 2013 5:52 am

I'm sure this should be easy with a simple while loop but I can't get it working.

I have 50 objects, which have either a 0 or a 1 in a variable, let's say it's called 'Value'. I want to choose one of them at random, which contains a 0 in 'Value'.

I was thinking...

While
Pick a random 'Object'
Object.Value=0
    Sub Event - Do my stuff.

But that's not working, not sure if picking in a 'while' works as I'm thinking it does. Or maybe there's just a much simpler way?

B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Mon Mar 04, 2013 5:58 am

So what you want to do is pick a random object that has a value of 0? I don't think you want a loop for that.

You might want to do something like this:
Event: Object.Value = 0
Sub Event: Pick a random object
SubSub Event: Do your stuff.

I'm not 100% on that though.Sushin2013-03-04 06:01:27
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Mon Mar 04, 2013 6:50 am

Hmm yeah, you're right, that should work I think... thanks.
B
25
S
5
G
3
Posts: 446
Reputation: 5,633


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest