[SCRIPT] Random variables - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] Random variables (/thread-23749.html) |
Random variables - Omenapuu - 10-30-2013 Hi everyone, and happy coding! I'm asking if anyone of you know how to use the RandInt code. I basically know the variables and so, but as I can't name the random int, how to I make an if-else statement about that. Heres an example what im talking about: -------- if(GetLocalVarInt("sounds") == 1 { PlayGuiSound("sumthing", 100); } ---------------- Now I want to make that like it generates a random int, if its 1 it plays something, if 2 if plays something else, and so on. I just don't understand how RE: Random variables - Omenapuu - 10-30-2013 (10-30-2013, 08:21 PM)Robosprog Wrote: Thanks! I totally forgot else if statements.. RE: Random variables - Adrianis - 10-31-2013 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 Code: int myRandomInt = RandInt(1, 8); 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 Code: int myRandomInt = RandInt(1, 3); You can read about switch..case statements here, under the 'Conditions' heading http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_statements.html RE: Random variables - PutraenusAlivius - 10-31-2013 http://www.frictionalgames.com/forum/thread-21190.html Random Scares and shit. |