How do I randomly choose a function

Just started using Construct 2? Post your questions here

Post » 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.

Thanks in advance
B
5
Posts: 14
Reputation: 260

Post » 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
ImageImageImageImageImage
B
54
S
15
G
5
Posts: 852
Reputation: 11,346

Post » 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

Post » 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: 517
Reputation: 5,206

Post » 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

Post » 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: 517
Reputation: 5,206

Post » Tue Aug 26, 2014 8:02 pm

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


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests