en:api:rng

# Random number generator

The RNG object is available as salet.rnd.

Unlike Math.random, Salet's version of RNG is predictable: the generator gives the same numbers when initialized with the same seed value. That's why it won't change the result after saving and loading the game.

The generator produces pseudo-random numbers with a perion of 2³². That should be enough for most games.

The multiplier, modulo, offset properties are system RNG properties. If you don't know what they are, you probably shouldn't change them.

2³² - 1 value.

Returns a pseudorandom integer number bigger or equal to 0 and less than modulo

Returns a pseudorandom floating point number bigger or equal to 0 and less than 1.

Returns a pseudorandom integer number bigger or equal to 0 and less than n Argument: a number n, any number

An alias for rand method.

Returns a random element from the supplied array.

Argument: an array of elements.

Returns a pseudorandom integer number bigger or equal to min and less than max. The number will be integer if min is integer too.

Argument 1: a number min, any number Argument 2: a number max, any number

Returns a result of throwing n dice which have dx faces each. The plus value is added to the result.

Argument 1: n - integer number
Argument 2: dx - integer number Argument 3: plus - a number, optional argument

Returns a result of throwing n dice which have dx faces each. The plus value is added to the result.

This method accepts one argument instead of three: a string in the form of NdX+plus. By default, plus = 0, n = 1

In addition to the usual number of faces, this method also understands cubes dF - the so-called "fudge dice", and d% - a percentage cube d100.

Argument 1: a string like NdX+plus

Returns a chance in percents of the value + the value that would be on a dice with n faces would be greater than the target value.

Argument 1: value - initial value Argument 2: target - target value Argument 3: n - amount of dice faces

The initial seed that initializes the generator. By default, Salet uses current time (with millisecond precision)

Argument: integer value that should be much less than modulo

The method that returns the seed value.

• en/api/rng.txt