Skip to content

irandom

CryoEagle edited this page Dec 30, 2018 · 4 revisions

irandom

Returns random whole number from 0 to n

Syntax:

irandom(n)
Argument Description
int n The upper range from which the random number will be selected.

Returns: int

Description:

This function will return number from 0 to your choosen upper range, it's similar like random(n); but this will return whole number.

NOTE: This function will return the same value every time the game is run afresh 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 behaviour use randomize at the start of your game.

Example:

int luck = irandom(3);
int score = 0;
if(luck == 2)
{
    score++;
}

This code will select random whole number from 0 to 3 for int luck, if luck will equals to 3 we add for player +1 score.

Back to number_functions

Clone this wiki locally