Randomly choosing between 2 variables

Get help using Construct 2

Post » Wed Feb 26, 2014 3:00 pm

Here is the thing folks.
I don't really know how to randomly choose between 2 variables in this form.

Image

I want that every from 10 to 60 seconds C2 chooses randomly between 2 variables that are listed here.

Any advices please?
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Wed Feb 26, 2014 3:12 pm

Use System.choose().

var1 = choose(var2,var3)
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Wed Feb 26, 2014 4:13 pm

blackhornet wrote:Use System.choose().

var1 = choose(var2,var3)


Thank you blackhornet! But I am wondering where do i have to enter this code?
I make a new variable which value will be set to trigger the var i need to randomize?
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Wed Feb 26, 2014 4:19 pm

choose() in the manual is under system expressions. an expression in the white box that requests an input value. there are a lot of excellent and helpful expressions listed in the manual :)

System.setvaribale
[variable box]
choose(var1, var2)
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Post » Wed Feb 26, 2014 4:36 pm

jayderyu wrote:choose() in the manual is under system expressions. an expression in the white box that requests an input value. there are a lot of excellent and helpful expressions listed in the manual :)

System.setvaribale
[variable box]
choose(var1, var2)


I knew about choose and random but i was wondering where to put those :)
now i see.
I would like to have some sort of event which will let me tap code without creating more variables.
But thanks i've got it. I will create a trigger variable triggering the 2 trigger variables :p
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Wed Feb 26, 2014 5:00 pm

It doesn't work :(

Where am I wrong?
Image

If BubbleRain_On=1 an event must happen but nothing happens.
Is my choose correct? Can i put BubbleRain_ON=1 and expect it to take value 1?
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Wed Feb 26, 2014 5:18 pm

Create a function called head or tails
Variable Heads_Tails Set variable Choose(0,1)

Now when you want to choose either call the function
System compare two values heads_tails equal to 0 do this
else
do that
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Wed Feb 26, 2014 5:20 pm

DUTOIT wrote:Create a function called head or tails
Variable Heads_Tails Set variable Choose(0,1)

Now when you want to choose either call the function
System compare two values heads_tails equal to 0 do this
else
do that


Thanks dude. The funny thing is that i figured it out just right now.
Works :)
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Wed Feb 26, 2014 6:09 pm

No Problem, the answer always comes at the end ha ha
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Feb 27, 2014 3:39 am

I so know that feeling. I was once told that it's the dummy model. Where just talking about a problem out loud will help you solve the problem. These days I know talk out loud. I find my self requiring a lot less to ask on forums :P
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013


Return to How do I....?

Who is online

Users browsing this forum: Clark Thy Lord and 1 guest