How do I.... random number but in 50 increments?

Get help using Construct 2

» Sat Sep 07, 2013 1:43 am

How do I have a random number between 100-600 but in increments of 50?

Currently I have: (random(round(100*0.05),round(600*0.05)))*150
but this is wrong.
Football Dash (1m+): GooglePlay | AppStore

www.lumicreative.com
B
82
S
31
G
8
Posts: 506
Reputation: 10,739

» Sat Sep 07, 2013 1:44 am

int(round(1-6)*100)
B
44
S
18
G
17
Posts: 2,249
Reputation: 17,585

» Sat Sep 07, 2013 1:58 am

Hmmm.. Doesn't seem to work. What I'm trying to do is spawn an object with X and Y coordinates. The suggestion doesn't seem to create random numbers between 100 - 600 in increments of 50. Instead, it seems to be subtracting 6 from 1 and then multiply by 100 every single time.
Football Dash (1m+): GooglePlay | AppStore

www.lumicreative.com
B
82
S
31
G
8
Posts: 506
Reputation: 10,739

» Sat Sep 07, 2013 3:17 am

int(random(0,11))*50 + 100
B
72
S
22
G
290
Posts: 3,886
Reputation: 159,513

» Sat Sep 07, 2013 4:12 am

@jook00
To explain @backhornet 's correct help a bit more: In cases like these just think about what you're trying to achieve mathematically.
100 to 600 in 50's increments.
range you need: 600 - 100 = 500
steps you need: 500 / 50 = 10 => + 1 = 11 (the incremments plus starting at zero)
producing 11 numbers from 0 to 10 inclusive: int(random(0,11))//or shorter: int(random(11))
random(0, 11) produces floats that are higher than 0 and lower than 11, e.g. 0.023 or 10.98
int() omits the fractional part => 0.023 becomes 0, 10.98 becomes 10
0 to 10 * 50 => a range of 500 in 50's increments
+ 100 => shifting to the desired start value of 100
B
24
S
8
G
10
Posts: 1,822
Reputation: 8,291