@rbxts/debug-random
v1.0.3
Published
A wrapper around Roblox's Random class that enables users to serialize and set the state of the Random object
Downloads
9
Readme
DebugRandom
A wrapper around Roblox's Random class that enables users to serialize and set the state of the Random object.
Get it here:
Documentation
Usage
Example use: Serialize a random number generator's state when an error occurs, so the error can be replicated using DebugRandom:SetSerializedState or DebugRandom.deserialize.
local rng = DebugRandom.new()
print(rng:NextNumber())
local state = rng:Serialize()
local deserializedRng = DebugRandom.deserialize(state)
assert(rng == deserializedRng)
assert(rng:NextNumber() == deserializedRng:NextNumber())
assert(rng == DebugRandom.fromString(tostring(rng)))