How do I create random percent scenarios

Get help using Construct 2

Post » Mon Sep 01, 2014 11:49 am

For example I have two scenarios X and Y.
When a button is pushed I want it so X pops up on the screen 80 percent of the time when the other 20 Y pops up.
Thank you for your help!
B
8
S
3
G
2
Posts: 52
Reputation: 1,762

Post » Mon Sep 01, 2014 11:56 am

something like
IF random(100) < 80 do X
ELSE do Y
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Sep 01, 2014 12:07 pm

Thanks I tried it, kinda worked, but I want to do something like SetText: X 80 percent of the time and Y 20 percent (it is not a condition but an action so can not do else)
B
8
S
3
G
2
Posts: 52
Reputation: 1,762

Post » Mon Sep 01, 2014 1:01 pm

You could use the choose() expression..

choose(x,x,x,x,y) should make 20% chance of y against 80% chance of x
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Sep 01, 2014 1:14 pm

@Tombufa

Use conditional expressions (essentially an if/else)

For example,
Set Text: random(100)<80 ? "" & X : "" & Y
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
33
S
9
G
7
Posts: 450
Reputation: 6,780

Post » Tue Sep 02, 2014 12:10 pm

thankyou everyone it now works
B
8
S
3
G
2
Posts: 52
Reputation: 1,762

Post » Tue Sep 02, 2014 1:22 pm

This was asked before, solution with capx if you still need them. Cheers!
B
28
S
8
G
4
Posts: 553
Reputation: 4,924


Return to How do I....?

Who is online

Users browsing this forum: tarek2, Yahoo [Bot] and 52 guests