Skip to content
Jake edited this page Aug 4, 2021 · 11 revisions

Useful links:


random( <array> )

Return a random value from an array

elements = [];
elements[elements.size] = "a";
elements[elements.size] = "b";
elements[elements.size] = "c";

random_value = random(elements); //a, b, or c

Include: common_scripts\utility


cointoss( )

Return a random boolean (50/50)

random_value = cointoss(); //true or false

Include: common_scripts\utility


randomVector( <num> )

Return a random vector centered on <num>

direction = randomVector(1);

Include: common_scripts\utility


randomVectorRange( <num_min>, <num_max> )

Return a random vector centered between <num_min> and <num_max>

direction = randomVectorRange(5, 10)

Include: common_scripts\utility


randomInt( <max> )

Return a random integer between 0 and <max>-1

random_value = randomInt(3); //possible contents: 0, 1, 2

randomIntRange( <min>, <max> )

Return a random integer between <min> and <max>-1

random_value = randomIntRange(2, 5); //possible contents: 2, 3, 4

randomFloat( <max> )

Return a random float in the range: 0 <= x < max

random_value = randomFloat(1); //could equal any number >= 0 and < 1

randomFloatRange( <min>, <max> )

Return a random float in the range: min <= x < max

random_value = randomFloatRange(1, 2); //could equal any number >= 1 and < 2