Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Random variables
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#3
RE: Random variables

You can totally 'name' a Random number, simply by creating a variable, then assigning to it the random number that RandInt or RandFloat gives you

int myRandomInt = RandInt(1, 8);

if (myRandomInt > 4)
{
    // do stuff
}

This will also allow you to use the super awesome Switch.. Case statements, to make a bunch of if..else if.. else if.. etc look nice

int myRandomInt = RandInt(1, 3);

switch (myRandomInt)
{
    case 1: // do stuff if random number is 1
        break;
    case 2: // do stuff if random number is 2
        break;
    case 3: // do stuff if random number is 3
        break;
}

You can read about switch..case statements here, under the 'Conditions' heading
http://www.angelcode.com/angelscript/sdk...ments.html

(This post was last modified: 10-31-2013, 03:12 AM by Adrianis.)
10-31-2013, 03:12 AM
Find


Messages In This Thread
Random variables - by Omenapuu - 10-30-2013, 07:49 PM
RE: Random variables - by Adrianis - 10-31-2013, 03:12 AM
RE: Random variables - by PutraenusAlivius - 10-31-2013, 07:40 AM



Users browsing this thread: 1 Guest(s)