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

Are we able to roll inside the API?

I would like to implement shadowruns extended tests which are actually a series of rolls with a varying dice pool where the successes are added up. To do this I would require the possibility to roll and access the results. Is there a script which does something similar where I could look how to access the roll engine?
You can use sendChat() to send dice to the quantum roller and then access that via the msg object. Powercards makes extensive use of that.
1455473761
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
"You can use this, for example, to perform a roll using the Roll20 roll engine, then get the results of the roll immediately. You could then perform additional modifications to the roll before sending it to the players in the game." <a href="https://wiki.roll20.net/API:Chat#sendChat.28speaki" rel="nofollow">https://wiki.roll20.net/API:Chat#sendChat.28speaki</a>...
1455493484
Lithl
Pro
Sheet Author
API Scripter
You can also use the randomInteger function to get a die value, essentially rolling it yourself. randomInteger(20) is roughly equivalent to using sendChat for /r d20
1455494593
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Brian said: You can also use the randomInteger function to get a die value, essentially rolling it yourself. randomInteger(20) is roughly equivalent to using sendChat for /r d20 I 100% agree with everything you posted.... but... based on how superstitious some humans are and how much human resist accepting random as random or accepting trends are part of randomness... I would never want to have the conversation about using two sources for in game roll results. And not trying to open that can of worms (it's been covered) just saying… likely best to just use one source for in game rolls. It nerfs some of the pettifog.
1455506712
The Aaron
Pro
API Scripter
From:&nbsp; <a href="https://wiki.roll20.net/API:Utility_Functions#Rand" rel="nofollow">https://wiki.roll20.net/API:Utility_Functions#Rand</a>... randomInteger(max) Use This Function For Dice! This function accounts for Modulo Bias which ensures that the resulting random numbers are also evenly distributed between 1 and MAX. Returns a random integer, with the lowest value being 1, and the highest value being max . This is the same functionality that Roll20 uses to power its dice rolls, and these numbers have been statistically and rigorously proven to be random. So it's really only a single source for those random numbers. &nbsp;=D
Is that updated for the quantum roll upgrade though?
1455513210
The Aaron
Pro
API Scripter
I'm pretty sure it is, but I'll verify and then update the wiki.
Cool, thank you. Will make my Adventure Game script easier to re-write then if that's true.
1455549616

Edited 1455549636
Riley D.
Roll20 Team
So, randomInteger() does not actually use QuantumRoll. The reason for this is that when we say "QuantumRoll", we're referring to not only the actual RNG itself, but also the things surrounding that RNG, including the source of entropy that seeds it and the fact that we sign the roll with our private key so that the client can verify it is a random, non-manipulated roll that was generated by our server. randomInteger() does use a very similar system to QuantumRoll (it's actually the same system we fall back to on the local client if we can't contact QuantumRoll), but since it's not outputting a fully-signed roll the way that sendChat() does, you won't for example get the little dice icon in the chat, it's not verified as non-manipulated, etc. So feel free to use randomInteger if you'd like, it's definitely random, but you just won't get all the extras that go with using QuantumRoll and sendChat(). I would say that if you are just wanting to generate a quick random number to use for something simple (e.g. picking a random card from a deck, rolling a random side on a multi-sided token, choosing a random item from a table, etc.) then randomInteger() is totally fine. If you are actually outputting a dice result that is similar to someone rolling "/r 1d20" in chat themselves, they I would recommend using sendChat() if possible since that is the closest match from an end-user perspective.