Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

random interger

i am not a scripter at all but i was wondering what is the way of doing a rnd command in ruby.

i was thinking that i could make random enemies appear at random times and drop random items

but i didn't see any kind of command like that in rpg maker xp.

i was thinking that in an event just say you would call a script, all the script would do was get a random integer between X and Y and then store it to a variable.

is that possible?
 
gratheo":2lsdx9me said:
Not sure about VX, but in XP there's an option to set a variable to a random integer between n and p in the events options.

well i was wondering about xp not vx

lol sorry i didn't specify

that would work i guess. lol i feel like a complete retard for not seeing that before. my bad =D. lol i am still curious of course if it is possible with ruby lol

thanks a lot tho =]
 
simply use
Code:
rand(x)
It will generate a random integer between 0 and x.

If you want your integer to start at a specific value, then use
Code:
x + rand(y)

Here's a little example
I want a number between 15 and 20. The code will look like
Code:
15 + rand(5)

Take care!
-Dargor
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top