random_set_seed

Sets the seed from which random numbers and outcomes are taken.

Syntax:

random_set_seed(val);


Argument Description
val The seed to set.


Returns: N/A


Description

To generate a random number GameMaker: Studio starts with a random seed number. With this function you can set that seed to a known value and so "force" the outcome of all random events afterwards to be the same every time the program is run. For example, this function can be used in conjunction with random_get_seed to create procedurally generated content and save the results without having huge savegames (you save the seed only, no need for anything else). Should you need truly random results for everything, you should be using the randomize() function.

NOTE: While this seed will give consistent results on each target platform, results may vary between platforms due to the different way each target works.


Example:

if debug random_set_seed(1);

The above code sets the random seed to 1 only if the variable "debug" is true.


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