Module RNG

Provides Random Number Generation Calling RNG() will always give back an instance with the same starting seed NOTE If functions are called as such RNG():FuncName, there will be no randomisation.

Ensure you always assign a variable with the return value of RNG()

Usage:

    -- Creating a new RNG instance
     local newRNG = RNG()
    

Info:

  • Author: Ennis Massey

Functions

__call () Constructor metamethod Constructs a new RNG instance
GetSeed () Gets the Seed used for RNG NOTE This is not the GAME seed.
Next () Function unknown, appears to return another seed value Likely used for multiple random number generations
RandomFloat () Returns a float between 0.0 and 1.0
RandomInt (Max) Returns an integer between 0 and Max (exclusive) the RNG seed is changed.
SetSeed (Seed, ShiftIdx) Sets the seed to use for the next RNG Both parameters seem to affect the RNG, but I’m not sure how ShiftIdx functions


Functions

__call ()
Constructor metamethod Constructs a new RNG instance

Usage:

    local newRNGInst = RNG()
GetSeed ()
Gets the Seed used for RNG NOTE This is not the GAME seed. It is unrelated to item, room and stage generation

Returns:

    integer Seed used for RNG

Usage:

    local newRNGInst = RNG()
     local rngSeed = newRNGInst:GetSeed()
Next ()
Function unknown, appears to return another seed value Likely used for multiple random number generations

Returns:

    int Another seed?
RandomFloat ()
Returns a float between 0.0 and 1.0

Returns:

    float random float

Usage:

    local rng = RNG()
     local randomFloat = rng:RandomFloat()
RandomInt (Max)
Returns an integer between 0 and Max (exclusive) the RNG seed is changed. If the Max is a negative number, it will return an unbound random integer.

Parameters:

  • Max integer maximum value

Returns:

    integer Random number between 0 and Max
SetSeed (Seed, ShiftIdx)
Sets the seed to use for the next RNG Both parameters seem to affect the RNG, but I’m not sure how ShiftIdx functions

Parameters:

  • Seed integer Value for RNG seeding
  • ShiftIdx integer Unknown. Will crash game if negative
generated by LDoc 1.4.6 Last updated 2017-07-17 09:37:29