Pick a number between 1 and 4

Get help using Construct 2

Post » Mon Feb 10, 2014 4:20 pm

How do i make Construct 2 pick between numbers?
I was thinking adding a variable and then having it randomly draw between 1 and X but i can't finger out how to do this. any tips?
B
14
S
4
G
1
Posts: 61
Reputation: 1,459

Post » Mon Feb 10, 2014 4:29 pm

expressions

You can use Choose, or Random (converted to an Int).
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Feb 10, 2014 4:32 pm

Thank you blackhornet
B
14
S
4
G
1
Posts: 61
Reputation: 1,459

Post » Mon Feb 10, 2014 5:13 pm

nOT SURE WHAT i'm doing wrong here.
I have it
a box for Answer1 with text in it
Then a trigger
system set Answer1 to Random (1,101)
Tower1 set text to Answer1

but nothing shows up
B
14
S
4
G
1
Posts: 61
Reputation: 1,459

Post » Mon Feb 10, 2014 5:19 pm

@CampingCarl

What's the trigger? Might want to check in debug mode that Random is actually being set.
B
25
S
6
G
3
Posts: 197
Reputation: 3,355

Post » Mon Feb 10, 2014 5:21 pm

it's all set to do on start of layout
B
14
S
4
G
1
Posts: 61
Reputation: 1,459

Post » Mon Feb 10, 2014 5:28 pm

I found the bug, Its doing .3213213 or something like that after, how do i make it round up or down?
B
14
S
4
G
1
Posts: 61
Reputation: 1,459

Post » Mon Feb 10, 2014 5:44 pm

int(Random (1,101))
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Feb 10, 2014 5:47 pm

WOOT thanks black hornet!
B
14
S
4
G
1
Posts: 61
Reputation: 1,459

Post » Mon Feb 10, 2014 5:50 pm

@CampingCarl For future reference, you can find a list of the possible expressions for rounding/converting variables here:
https://www.scirra.com/manual/126/system-expressionsTwinTails2014-02-10 17:50:37
B
25
S
6
G
3
Posts: 197
Reputation: 3,355

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests