True RNG

Latest version1.0.6
Minimum Core0.7.9
Compatible Core0.8.6
File size0 B
Last updated2 years ago
Created3 years ago
Systems All systems
Project source Project URL
Report bugs Bug tracker URL
Read-me Readme URL


# TrueRNG

This module implements's true random number generator service into the dice rolls of Foundry-VTT. In order to use the module you will need to generate a free api key from


## Installation

* Install the module using the following manifest url:

* As GameMaster go to the "Module Settings" tab inside "Configure Settings" and paste in your api key under " API Key"

* Save Changes. The clients will now all start pulling in random numbers from


## Configuration

` API Key`[Global] - Required in order to function properly. If you don't provide an api key then Foundry's original random number generator is used.


`Max Cached Dice`[World] - This is the amount of random numbers to pull in at a time for each client. The developer api key is limited on how many numbers it can generate in a day. 

So if you have a large number of players or reload the game a lot throughout the session I recommend keeping this `low`.

If you are playing a game that requires rolling large quantities of dice then I recommend setting this `high`.


`Update Point`[World] - Every time a dice is rolled the client checks how many cached values it has left. With the default values it will pull in 50(Max Cached Dice) once it falls below 50%(Update Point). 

In that example at 25 cached dice it will generate 50 more random numbers and add them to the existing cache. Again adjust this value based of the number of rolls you do in your game at once. 


`Print Debug Modules`[Client] - Prints debug messages into console used during debugging. Can be used to make sure the module is running correctly.


`Enabled`[World] - Enables/Disables the module for everyone in the server.


`Show Quick Toggle Button`[Client/GM] - Toggles the visibility of a button that turns the Enabled setting on and off. Visible only to the gm.



## Implementation Notes

When the module is loaded it replaces the cached random number generator function in `CONFIG.Dice.randomUniform` with it's own `TrueRNG.GetRandomNumber` 

as well as caching the original in case of user/server error. It will then generate some server settings and try to grab the current api key. 

If the api key exists then it makes a request to immediately, otherwise it will wait for an api key to be set before trying again.

The random numbers are stored in an array and are unique for each client as it turns out that the dice rng function is client sided.

Once the client rolls a dice it will get the current time in milliseconds and modulus it by the length of the current cached values. 

I did this because I didn't like the idea of a players role being predetermined at the start of each game. 

This at least makes it so that the rolls you get are determined at the start, the order that you get them is random.



If you like this repo and want to support me you can always buy me a pizza 😁

<a href="" target="_blank"><img src="" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>


Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x