random_func_2

Generates a random value between 0 and high_value, not including high_value. If called on the same frame with the same index, this function will always return the same value (making it replay-safe).

ArgumentTypeDescription
index:realIndex of the function call, must be between 0 and 200
high_value:realThe high end of the range from which the random number will be selected
floored:realIf the number returned should only be a whole number

Example, called from update.gml:

// creates 5 articles
// and sets their hsp and vsp to random whole numbers between 5 and 10:

for (var i = 0; i < 5; i++) {
var this_article = instance_create( x, y, "obj_article1" );
this_article.hsp = spr_dir * (5 + random_func_2( 2 * i, 6, true ) );
this_article.vsp = -5 - random_func_2( 2 * i + 1, 6, true );
}

Note that the first argument of each separate function call is different, otherwise they would return the same number!