-
-
Notifications
You must be signed in to change notification settings - Fork 18
irandom
CryoEagle edited this page Jan 14, 2019
·
4 revisions
Returns random whole number from 0 to n
irandom(n)
Argument | Description |
---|---|
int n |
The upper range from which the random number will be selected. |
Returns: int
This function will return a random integer from 0 to your chosen upper range, it is similar to random(n);
but this will return a whole number rather than a decimal.
NOTE: This function will return the same value every time the game is run due to the fact that SimplexRpgEngine generates the same initial random seed every time to make debugging code a far easier task. To avoid this behavior, use randomize()
at the start of your game.
int luck = irandom(3);
int score = 0;
if(luck == 2)
{
score++;
}
This code will select a random whole number from 0 to 3 for int
luck, if luck equals 2 we add 1 to the score variable.
Back to number_functions