listRandom function

Syntax

  • float listRandom(stringList)

Parameters

  1. stringList—string

Returns

Returns random item of stringList.

Description

The listRandom function returns a random item of the stringList.

Note:

  • Getting a random element often is directly combined with a wildcard search. See example.2.
  • Stringlists are a series of strings stored inside one string. The elements are separated by a semicolon (";"). Each item must be followed by a semicolon, also the last one! The data type is "string", thus it is not an array as used in other scripting languages.

Related

Examples

example.1
	listRandom("rule;your;city;")
	# result = "rule" or "your" or "city" 

example.2
	listRandom(fileSearch("/myProject/assets/*.jpg"))
	# result = a random .jpg image from that directory.
	
example.3
	listRandom(fileSearch("*.obj"))
	# result = a random asset from the whole workspace.

In this topic