Game Maker's Garage Forum

Game Creation => SilverCreator => Topic started by: Xiphos on December 12, 2009, 09:35:00 PM

Title: Random code
Post by: Xiphos on December 12, 2009, 09:35:00 PM
How to make it so random(3) doesn't have the option of 0.
random(2)+1 doesn't work.
Title: Re: Random code
Post by: Al Staffieri on December 13, 2009, 07:51:37 AM
LET X = RANDOM(2)
LET X = X + 1
Title: Re: Random code
Post by: Xiphos on December 13, 2009, 12:05:08 PM
thanks
Title: Re: Random code
Post by: EqwanoX on December 13, 2009, 07:04:14 PM
(this is sc help right?) wha?! random(3) doesnt have the option of 0
Title: Re: Random code
Post by: GMG Mike on December 19, 2009, 02:11:17 PM
SilverCreator would have no problem doing RANDOM(2)+1, so I'm going to assume that this is a GM question and move it to the GM board.
Title: Re: Random code
Post by: Al Staffieri on December 20, 2009, 10:14:23 AM
Hmm. I thought it was for SilverCreator. GameMaker will give you a random number from 1 to the number you put in the command.

x = RANDOM 3
will give a result from 1 to 3


If you put multiple parameters after RANDOM then it will give you a random number of any of the numbers listed.
x = RANDOM 5 10 15 20
will give a result as either 5, 10, 15, or 20.
Title: Re: Random code
Post by: GMG Mike on December 21, 2009, 10:11:49 PM
I think you're right. GM doesn't use LET or parenthesis. Push it back to the SC board.
Title: Re: Random code
Post by: Al Staffieri on December 22, 2009, 09:43:06 AM
Actually GM can use LET. It's optional. I added that a while back to make code more compatible between SC and GM. I think code even runs slightly faster if you use LET instead of using nothing.

I'll push it back to the SC board anyway because I think he was using SC.