Skip to main content

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)))