Topic:   Random code   (Read 18644 times)


0 Members and 1 Guest are viewing this topic.

Xiphos


  • GMG-er

  • **


  • Posts: 676
Random code
« 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.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Random code
« Reply #1 on: December 13, 2009, 07:51:37 AM »
LET X = RANDOM(2)
LET X = X + 1

Xiphos


  • GMG-er

  • **


  • Posts: 676
Re: Random code
« Reply #2 on: December 13, 2009, 12:05:08 PM »
thanks

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: Random code
« Reply #3 on: December 13, 2009, 07:04:14 PM »
(this is sc help right?) wha?! random(3) doesnt have the option of 0

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Random code
« Reply #4 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.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Random code
« Reply #5 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.

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Random code
« Reply #6 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.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Random code
« Reply #7 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.