Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Query] Seed the random number generator?

Is it possible to seed the random number generator? I did some searching, and found previous posts that imply not, but they weren't definitive and were over a year old. Plus with an updated random number generator on the horizon, even if the answer is no today, it might change.
1420487202
Lithl
Pro
Sheet Author
API Scripter
Neither Javascript's Math.random function nor the randomInteger function available for API scripts allows setting a seed. If you need to have the ability, there are a couple nice suggestions for how to implement it in JavaScript on StackOverflow . I particularly like the solution from Remco Kranenburg: Math.seed = function(s) { return function() { s = Math.sin(s) * 10000; return s - Math.floor(s); }; }; Three of Swords said: Plus with an updated random number generator on the horizon, even if the answer is no today, it might change. Not sure what you're talking about "on the horizon"?
Oops. I guess it's the 3D dice that are changing, not the actual random number generator. My bad. As for the seed, thanks for the suggestion.