Package Exports
- @rbxts/debug-random
- @rbxts/debug-random/src/init.luau
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rbxts/debug-random) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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)))