random_get_seed

Returns the current random seed.

Syntax:

random_get_seed();


Returns: Real


Description

To generate a random number GameMaker: Studio starts with a random seed number. With this function you can retrieve that seed, which can then be stored to reproduce a specific series of random events. For example, say you have a procedurally generated game, but want the player to be able to go back to previously discovered areas. Well, at the start of each area, you can store the random seed with this function and so every time you need to go back there, you can use random_set_seed to set the seed to what it was previously and so force GameMaker: Studio to reproduce the same set of "random" functions that it used previously.


Example:

ini_open("Save.ini")
ini_write_real("Levels", string(level), random_get_seed());
ini_close();

The above code will get the random seed and store it in an ini file.


Back: Real Number Functions
Next: random_use_old_version
© Copyright YoYo Games Ltd. 2018 All Rights Reserved