# How do I randomly choose a function

Just started using Construct 2? Post your questions here

### » Sat Aug 23, 2014 8:08 pm

Hi,

I have no idea if it's possible... Say I have ten functions ( F1 - F10), is it possible to call randomly one of them.

I want to use it like this:
After answering a question the player could be right or wrong. I want all kinds of things happening after the answer is given, but not every time the same things, after every right or wrong answer. So I like that randomly is chosen what the player is hearing and seeing after every answer he gaves.

B
5
Posts: 14
Reputation: 260

### » Sat Aug 23, 2014 8:12 pm

you could use: When The player is right ===> call function: Choose("f1","f2","f3") and so one
hope it works
B
58
S
17
G
5
Posts: 852
Reputation: 11,611

### » Sat Aug 23, 2014 9:11 pm

Thanks for the quick reply. This is exactly what I was looking for, but could not find. Great, I will use it!
B
5
Posts: 14
Reputation: 260

### » Sat Aug 23, 2014 10:30 pm

Also: "F" & ceil(random(10))
Note that random expression is 0 based and will give float numbers so ceil will round it up to closest whole number.
Last edited by Katala on Sat Aug 23, 2014 10:35 pm, edited 1 time in total.
B
34
S
9
G
3
Posts: 519
Reputation: 5,280

### » Sat Aug 23, 2014 10:32 pm

Katala wrote:Also: "F" & random(10)
Note that is 0 based so "F" & random(10)+1 if you dont have F0

You'd want int( random(10))
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Sat Aug 23, 2014 10:37 pm

@codah I was bit too slow
Also int( random(10)+1)
B
34
S
9
G
3
Posts: 519
Reputation: 5,280

### » Tue Aug 26, 2014 8:02 pm

Everybody thanks so much for your help.
B
5
Posts: 14
Reputation: 260