Random Integer

12wwood

New Member
Joined
Mar 5, 2019
Likes
1
#1
I need to generate two random integer, one with a range of 1 to 620 and another with a range of 1 to 420. I have no idea how I would go about doing this. Can someone give me a hand? Thanks.
 
Joined
Dec 13, 2018
Likes
16
Location
UK
#2
Type in 'Rnd' then making sure the cursor is within the word press F1. You'll find:

Function Rnd : Float ( range:Float )
and
Function Rnd : Float ( low:Float, high:Float )

You then need to convert the result to an integer using Int(n)

You could use either of these functions (add 1 to the result of the first version)

Have a go yourself, it's literally one line of code and it's better than someone just giving you the answer straight off :D
 

12wwood

New Member
Joined
Mar 5, 2019
Likes
1
#3
Type in 'Rnd' then making sure the cursor is within the word press F1. You'll find:

Function Rnd : Float ( range:Float )
and
Function Rnd : Float ( low:Float, high:Float )

You then need to convert the result to an integer using Int(n)

You could use either of these functions (add 1 to the result of the first version)

Have a go yourself, it's literally one line of code and it's better than someone just giving you the answer straight off :D
cheers mate, I literally just wasn't sure of what the command was and how you could use it but you basically gave me everything i needed to know. you're a legend.
 

12wwood

New Member
Joined
Mar 5, 2019
Likes
1
#4
cheers mate, I literally just wasn't sure of what the command was and how you could use it but you basically gave me everything i needed to know. you're a legend.
I am using monkey X and not Cerberus x, is this an issue?
 

12wwood

New Member
Joined
Mar 5, 2019
Likes
1
#7
I don't think so. May i ask why you use MX?
Btw. Look into the Seed command too when you want to randomize numbers.
because it was recommended to me when doing my project. i have switched to cerberus x now though as i found that it could open my code created in MX.
 
Top Bottom