How do I use random/choose to select whole number

Get help using Construct 2

Post » Sun May 22, 2016 3:13 am

Hi, I am currently trying to work on a life simulation game. I made a few pieces of code, labeled

On human| Created|Human|Set search to random(0,2)

I also tried choose(0,1,2) but both of these would always give me something like 0.54291243 or 1.30219423, so
how do I only have the outcome be 0,1, or 2?

Thanks in advance :D
B
15
S
5
Posts: 22
Reputation: 1,062

Post » Sun May 22, 2016 3:17 am

Use round(random#) instead
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
68
S
17
G
8
Posts: 637
Reputation: 9,420

Post » Sun May 22, 2016 3:19 am

floor(random(0,2)), int(random(0,2))
these also work
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Sun May 22, 2016 3:26 am

Thanks guys!
B
15
S
5
Posts: 22
Reputation: 1,062

Post » Sun May 22, 2016 3:28 am

int(random(0,3)) to get 0,1,2.

choose(0,1,2) should work fine.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider] and 47 guests