# 55 Condition Test

Get help using Construct 2

### » Wed Jul 31, 2013 10:01 pm

Hi.

I need to set a flag between 55 specific conditions.

Thought about rolling a random number, such as int(random (0,55)), but that would not be fair since there would be many fractional values, so in essence occasionally some numbers would be favored.

Thought about using Choose (a, b, c) since that gives equal chance to a, b, c, but could not find how to access it in the software? Does not seem to be under System.
B
43
S
21
G
18
Posts: 280
Reputation: 13,231

### » Wed Jul 31, 2013 10:07 pm

It's an expression, not an action. So, for example, you'll set the value of a variable to choose(a,b,c).

Using floor(random(55)) should give you what you want without favouring any numbers, though.
B
57
S
15
G
11
Posts: 912
Reputation: 12,656

### » Wed Jul 31, 2013 10:11 pm

Thank you.
B
43
S
21
G
18
Posts: 280
Reputation: 13,231

### » Wed Jul 31, 2013 10:12 pm

[QUOTE=GeometriX]floor(random(55))[/QUOTE]
secondd'
B
18
S
5
G
4
Posts: 568
Reputation: 5,084

### » Wed Jul 31, 2013 10:27 pm

Would there be a more elegant solution other than designing 55 different if/then branches? With an array maybe? Instance variables off a spawner?

Basically on Condition X (the rolled number from 0 to 55), I need to spawn specific objects for each number while randomizing their size and speed.

I need to think on this some more.

(It's late.)
B
43
S
21
G
18
Posts: 280
Reputation: 13,231

### » Fri Aug 02, 2013 4:15 am

Arrays are underutilized and very favorable for repetitive tasks.
They can eliminate many logic steps.

X=floor(random(55))
array(0-54,0) stores 1st set of data for conditions 0-54
array(0-54,1) stores 2nd set of data for conditions 0-54
array(0-54,n) stores n set of data for conditions 0-54

then using x as the condition variable...plug the values from array into appropriate conditions and spawnings etc...

spawn array(x,0) Monsters at array(x,1) x axis and array(x,2) y axis with a speed of array(x,3)

or random x,y, speed....
spawn array(x,0) Monsters at floor(random(array(x,1)) x axis and floor(random(array(x,2)) y axis with a speed of floor(random(array(x,3))

taking it one step further, the Monsters spawned could be stored in array(x,4) so that more than 1 type of monster could be picked.
B
5
S
1
Posts: 26
Reputation: 427

### » Wed Aug 07, 2013 4:20 am

Thank you, Kosiam.

That's very interesting.

So far I haven't used an array yet because I've been able to find simpler alternatives (such as spawning a random frame out of 54) for the same object for some variety, but I know eventually I'll have to get to arrays and that sounds like a very useful solution that affords a lot of complexity and control.
B
43
S
21
G
18
Posts: 280
Reputation: 13,231