Skip to reading
GDScript Programming & Godot

RandomInt()

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
On this page
Code example
RandomInt(minimum: int, maximum: int) -> int

Alias route for RandomInteger.

Returns: Integer.

Code example
RandomInt(1, 6)

RandomNumber()#

Code example
RandomNumber(minimum: float = 0.0, maximum: float = 1.0) -> float

Alias route for RandomFloat.

Returns: Float.

Code example
RandomNumber(0.0, 1.0)

Choose()#

Code example
Choose(values: Array, fallback: Variant = null) -> Variant

Pick an array entry, or a fallback for an empty array.

Returns: Selected value or fallback.

Code example
Choose(["Locked.", "Still locked."], "No reply.")

Shuffle()#

Code example
Shuffle(values: Array) -> Array

Make a deeply duplicated array and shuffle the copy.

Returns: Array.

Code example
Shuffle(["red", "green", "blue"])

Contained Object references are still objects, not independently cloned scenes.

Page 85 of 378Permalink
Go to page