Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
var myRandom = random(3);
if (myRandom < 1)
{
[stuff happens];
}
A good way to go about this, possibly:
Rounding the number guarantees you'll get one of six possible outcomes (0 counts as an outcome in this case). You can get slightly different results by changing round out for ceil (always round up) or floor (always round down), but in the case of the latter you'd want to use floor(random(6)), which should still always generate an outcome between 0 and 5 (random numbers never entirely hit the cap you put in place).
After that you'd want to use something like a switch statement, and check my syntax here as I'm working from memory:
What I'm unsure of here is if it needs brackets, but I'm pretty sure that's solid?
Looking up how switch statements work would do you only favors, but for the general gist, the "switch" here is the random number, and what that comes out to (case) determines where things start operating. The break statment tells the program to stop dealing with the switch at that point; not putting in a break can have some interesting results and can be used to your advantage, but generally you'd want one.
An alternative would be a series of ifs and else ifs, but for a situation where one variable can produce a lot of different results, a switch statement is usually your most efficient bet.