random_set_seed

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

Syntax:

GML Code Example

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:

GML Code Example

if debug random_set_seed(1);

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





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here