RandomInt - Utility: Difference between revisions

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Jlundin
No edit summary
 
m (Convert source tags to syntaxhighlight)
 
Line 6: Line 6:


== Syntax ==
== Syntax ==
<source lang="papyrus">
<syntaxhighlight lang="papyrus">
int Function RandomInt(int aiMin = 0, int aiMax = 100) native global
int Function RandomInt(int aiMin = 0, int aiMax = 100) native global
</source>
</syntaxhighlight>


== Parameters ==
== Parameters ==
Line 20: Line 20:


== Examples ==
== Examples ==
<source lang="papyrus">
<syntaxhighlight lang="papyrus">
; Get a random number between 0 and 100
; Get a random number between 0 and 100
int random = Utility.RandomInt()
int random = Utility.RandomInt()
</source>
</syntaxhighlight>
<br>
<br>
<source lang="papyrus">
<syntaxhighlight lang="papyrus">
; Get a random number between 0 and 10
; Get a random number between 0 and 10
int random = Utility.RandomInt(0, 10)
int random = Utility.RandomInt(0, 10)
</source>
</syntaxhighlight>


== See Also ==
== See Also ==
*[[Utility Script]]
*[[Utility Script]]
*[[RandomFloat - Utility]]
*[[RandomFloat - Utility]]

Latest revision as of 20:16, 5 September 2026

Member of: Utility Script

Generates a random integer between the minimum and maximum values (inclusive).

Syntax[edit | edit source]

int Function RandomInt(int aiMin = 0, int aiMax = 100) native global

Parameters[edit | edit source]

  • aiMin: The minimum value for the random integer.
    • Default: 0
  • aiMax: The maximum value for the random integer.
    • Default: 100

Return Value[edit | edit source]

A random integer between aiMin and aiMax (inclusive)

Examples[edit | edit source]

; Get a random number between 0 and 100
int random = Utility.RandomInt()


; Get a random number between 0 and 10
int random = Utility.RandomInt(0, 10)

See Also[edit | edit source]