User Tools

Site Tools


crpl:docs:randint

This is an old revision of the document!


<- CRPL reference <- Utility Commands

RandInt

ArgumentsResultNotation
Min, MaxRandom Integer n1 n2 – n2

Description

Pops Min and Max from the stack and pushes a random integer to stack where min ⇐ RandInt < max.

Note: Min may be higher than Max, however the resulting value will follow a different rule where min >= RandInt > max

Examples

#Creates a dancing number readout. Very high tech hackery.
0 10 RandInt
0 10 RandInt concat
0 10 RandInt concat
0 10 RandInt concat
SetPopupText
    
:awake
  TRUE OperateWhilePaused
# Showcases the difference between passing (Low, High) or (High, Low) into the function.
once
    ClearTraceLog
    ShowTraceLog
    50 0 do 
        #       min  max                     results         logic
        "lohi " -2    2   RandInt " "     #  -2 -1 0 1       min <= RandInt < max
        "hilo "  2   -2   RandInt Trace5  #     -1 0 1 2     min >= RandInt > max
    loop
endonce
crpl/docs/randint.1590531798.txt.gz · Last modified: 2020/05/26 18:23 by Sanian