choose(val0, val1, val2... val15);
|val0... val15||An input value that can be string, integer, variable or constant.|
Returns: One of the given arguments.
Sometimes you want to specify something other than numbers for a
random selection, or the numbers you want are not in any real order
or within any set range. In these cases you would use choose() to
generate a random result. For example, say you want to create an
object with a random sprite at the start, then you could use this
function to set the sprite index to one of up to 16 sprites.
NOTE: This function will return the same value every time the game is run afresh due to the fact that GameMaker: Studio generates the same initial random seed every time to make debugging code a far easier task. To avoid this behaviour use randomize at the start of your game.
sprite_index = choose(spr_Cactus, spr_Flower,
hp = choose(5, 8, 15, 32, 40); name = choose("John", "Steven", "Graham", "Jack", "Emily", "Tina", "Jill", "Helen");
The above code uses choose to set a number of properties for the instance.