Random expression

For questions about using Classic.

Post » Fri May 13, 2011 3:30 am

I'm using Construct Classic R1 (not 1.1). I built 4 layouts, and in Layout 1 I input a random expression to randomly move to different layouts on a button press:

Button B is down > + System Go To layout random(4) with transition 'None' lasting 0 MS

Overall it works and does randomly jump, except for some reason it decides to close the window often instead of jumping to another layout. Is there something with the expression that could be causing it?
B
12
S
4
G
3
Posts: 426
Reputation: 2,458

Post » Fri May 13, 2011 3:53 am

Random is zero based.
Do you have a layout 0?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri May 13, 2011 4:10 am

Could you rephrase that? I'm not certain of what you mean. I have Layouts 1,2,3 and 4.
B
12
S
4
G
3
Posts: 426
Reputation: 2,458

Post » Fri May 13, 2011 4:13 am

zero based mean if you use random(4)

the following number will be generated

0 1 2 3 4

so add +1 at the end like;

random(4)+1
B
3
S
2
G
2
Posts: 136
Reputation: 1,347

Post » Fri May 13, 2011 4:26 am

[quote="thoughtzone":tu1oywvk]zero based mean if you use random(4)

the following number will be generated

0 1 2 3 4

so add +1 at the end like;

random(4)+1[/quote:tu1oywvk]

Okay I see. I initially tried to do something like (4+1) and was getting a better result but ultimately the same problem, I didn't think to go outside the parentheses with it for some reason. Thanks guys. Solved:

How To Randomly Jump To Different Layouts
B
12
S
4
G
3
Posts: 426
Reputation: 2,458

Post » Fri May 13, 2011 9:27 am

[quote="thoughtzone":47yhqanj]if you use random(4), the following number will be generated:

0 1 2 3 4[/quote:47yhqanj]

Clarification: random(4) will give: 0, 1, 2, or 3
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest