Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Thu 14/08/2003 02:02:41

Title: Random Number Generation
Post by: on Thu 14/08/2003 02:02:41
Is there a plugin or a standard function for generating a Random number? ???
Title: Re:Random Number Generation
Post by: Dr Snark on Thu 14/08/2003 02:34:49
Random
Random (int max)

Returns a random number between 0 and MAX. This could be useful to do various effects in your game.
NOTE: The range returned is inclusive - ie. if you do Random(3); then it can return 0, 1, 2 or 3.

Example:

int ran=Random(2);
if (ran==0) NewRoom(1);
else if (ran==1) NewRoom(2);
else NewRoom(3);

will change the current room to room 1,2 or 3 depending on a random result.


Taken Directly From the MANUAL

RTFM!
Title: Re:Random Number Generation
Post by: TerranRich on Thu 14/08/2003 07:18:56
QuoteRTFM!

Indeed. NEW RULE! All posts will be locked if the answer is easily found in the AGS manual. Thank you, buh-bye.