How do I get a Random number

Get help using Construct 2

Post » Wed Oct 15, 2014 7:23 pm

I hope there is someone who can help here :)
how do I get a random number between 1 and 20, but it may not be able to choose 3 and 15
B
7
S
1
Posts: 8
Reputation: 954

Post » Wed Oct 15, 2014 7:32 pm

value = choose(1,2,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20)
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Wed Oct 15, 2014 7:36 pm

Random(N) - Returns a random number between 0 and N, not including N. The result includes fractions, so random(3) can return 2.5. Use floor(random(n)) to generate a random whole number up to but not including N, e.g. floor(random(3))* will return either 0, 1 or 2. Random(A, B) can also be used to generate a random number between A and B.

And you compare the result and re-roll accordingly.
B
35
S
9
G
3
Posts: 493
Reputation: 4,092

Post » Wed Oct 15, 2014 10:10 pm

hi thanks for answer

is it possible to use a variable in the choose function.
B
7
S
1
Posts: 8
Reputation: 954

Post » Wed Oct 15, 2014 10:12 pm

blackhornet wrote:value = choose(1,2,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20)

hi thanks for answer

is it possible to use a variable in the choose function.
B
7
S
1
Posts: 8
Reputation: 954

Post » Wed Oct 15, 2014 11:52 pm

Yes.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Thu Oct 16, 2014 1:30 am

jep77 wrote:
blackhornet wrote:value = choose(1,2,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20)

hi thanks for answer

is it possible to use a variable in the choose function.


Would've been quicker just to try that in C2? :) It's all about experimentation. Try something and see :D
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Oct 17, 2014 2:44 pm

I think like it:
You do not have the required permissions to view the files attached to this post.
B
8
S
1
Posts: 36
Reputation: 526


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 8 guests