Core.random: Difference between revisions
No edit summary |
mNo edit summary |
||
| (8 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
'''Available since:''' Gideros 2017.9<br/> | |||
''' | '''Class:''' [[Core]]<br/> | ||
=== | |||
=== Description === | |||
Generates and returns a pseudo random number. The random number sequence is guaranteed to be consistent across devices for a given seed. | |||
<syntaxhighlight lang="lua"> | |||
< | |||
() = Core.random(generator,bound1,bound2) | () = Core.random(generator,bound1,bound2) | ||
</ | </syntaxhighlight> | ||
=== | |||
'''generator''': (number) | If bounds aren't specified, the function will return a floating point number between 0 and 1. | ||
'''bound1''': (number) | |||
'''bound2''': (number) | If one bound is specified, the function will return an integer number between 1 and that bound (inclusive). | ||
=== | |||
''' | If both bounds are specified, the function will return an integer between bound1 and bound2. bound2 must be greater than bound1. | ||
=== Parameters === | |||
'''generator''': (number) PRNG algorithm to use, use 0 for default engine (MT19937) '''optional'''<br/> | |||
'''bound1''': (number) first bound of the range returned number must be in '''optional'''<br/> | |||
'''bound2''': (number) second bound of the range returned number must be in '''optional'''<br/> | |||
=== Return values === | |||
'''Returns''' () random number<br/> | |||
{{Core}} | |||
Latest revision as of 16:06, 29 November 2025
Available since: Gideros 2017.9
Class: Core
Description
Generates and returns a pseudo random number. The random number sequence is guaranteed to be consistent across devices for a given seed.
() = Core.random(generator,bound1,bound2)
If bounds aren't specified, the function will return a floating point number between 0 and 1.
If one bound is specified, the function will return an integer number between 1 and that bound (inclusive).
If both bounds are specified, the function will return an integer between bound1 and bound2. bound2 must be greater than bound1.
Parameters
generator: (number) PRNG algorithm to use, use 0 for default engine (MT19937) optional
bound1: (number) first bound of the range returned number must be in optional
bound2: (number) second bound of the range returned number must be in optional
Return values
Returns () random number
- Core
- Core.asyncCall
- Core.asyncThread
- Core.class
- Core.enableAllocationTracking
- Core.fileLoad
- Core.fileSave
- Core.findReferences
- Core.frameStatistics
- Core.getScriptPath
- Core.profilerReport
- Core.profilerReset
- Core.profilerStart
- Core.profilerStop
- Core.random
- Core.randomSeed
- Core.setAutoYield
- Core.signal
- Core.stopping
- Core.yield
- Core.yieldable
- Core.yieldlock