Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

irandom

CryoEagle edited this page Jan 14, 2019 · 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 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.

Example:

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

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /