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

Die roll takes a long time to resolve

1494728368

Edited 1494731290
Ada L.
Marketplace Creator
Sheet Author
API Scripter
For a character sheet I'm working on, I'm implementing a roller button for a special exploding dice mechanic that sort of goes like the following: The player rolls a single die, like a d6. If the result is the highest number on that die, then roll the next largest die up (d8) and keep the higher of the two rolls. Continue this pattern up to a d20 each time the maximum result is rolled on the die.  For a d12, the dice equation I have isn't too bad.  {1d11, floor(1d12/12)*{1d0 + 12, 1d20}k1}k1 In Javascript, this might be equivalent to: var d12 = Math.ceil(Math.random()*12); var d20 = Math.ceil(Math.random()*20); if(d12 === 12) return Math.max(12, d20); else return d12; For a d10, it gets a little more complicated and some slowdown is noticeable when it is processed: {1d9, floor(1d10/10)*{1d0 + 10, {1d11, floor(1d12/12)*{1d0 + 12, 1d20}k1}k1}k1}k1 In Javascript, this might be equivalent to: var d10 = Math.ceil(Math.random()*10); var d12 = Math.ceil(Math.random()*12); var d20 = Math.ceil(Math.random()*20); if(d10 === 10) { if(d12 === 12) return Math.max(12, d20); else return d12; } else return d10; ...and so forth. For d6 and lower though, the dice system seems to have so much trouble processing it that it causes Chrome to crash. Since it's not even a combinatoric equation, I wouldn't expect it to take such a long time to compute, especially since it only has to process groups of 2 at a time in any of these equations (albeit nested groups of 2).  Here's the equation for exploding a d4 with this mechanic:  {1d3, floor(1d4/4)*{1d0 + 4, {1d5, floor(1d6/6)*{1d0 + 6, {1d7, floor(1d8/8)*{1d0 + 8, {1d9, floor(1d10/10)*{1d0 + 10, {1d11, floor(1d12/12)*{1d0 + 12, 1d20}k1}k1}k1}k1}k1}k1}k1}k1}k1}k1 From the Chrome development console, here is a sample of output first from exploding a d10 with this system (finishes after a second), and then exploding a d6 with it (stuck in limbo). // The d10 roll: app.js?1494260277:44 Begin processing op! app.js?1494260277:44 Levels deep: 0 app.js?1494260277:44 Finished 0 app.js?1494260277:44 Levels deep: 0 app.js?1494260277:44 Inline rolls complete! app.js?1494260277:42 Descending into madness... app.js?1494260277:42 Descending into madness... app.js?1494260277:42 Descending into madness... app.js?1494260277:42 Descending into madness... app.js?1494260277:44 Finished after going 2 levels deep. // The d6 roll: app.js?1494260277:44 Begin processing op! Levels deep: 0 app.js?1494260277:31 Firebase Offline app.js?1494260277:35 Player -abc123 is offline... app.js?1494260277:44 Finished 0 app.js?1494260277:44 Levels deep: 0 app.js?1494260277:44 Inline rolls complete! firebase.2.4.0.js:106 Uncaught Error: Firebase.setWithPriority failed: First argument path specified exceeds the maximum depth that can be written (32) or object contains a cycle in property 'campaign-abc123-abc123.chat.-abc123.inlinerolls.0.results.rolls.0.rolls.1.3.rolls.1.0.rolls.1.3.rolls.1.0.rolls.1.3.rolls.1.0.rolls.1.3.rolls.0.0.type'     at of (firebase.2.4.0.js:106)     at nf.push (firebase.2.4.0.js:105)     at firebase.2.4.0.js:124     at Fb (firebase.2.4.0.js:28)     at hg (firebase.2.4.0.js:123)     at firebase.2.4.0.js:124     at Fb (firebase.2.4.0.js:28)     at hg (firebase.2.4.0.js:123)     at firebase.2.4.0.js:124     at Fb (firebase.2.4.0.js:28) of @ firebase.2.4.0.js:106 nf.push @ firebase.2.4.0.js:105 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 (anonymous) @ firebase.2.4.0.js:124 Fb @ firebase.2.4.0.js:28 hg @ firebase.2.4.0.js:123 gg @ firebase.2.4.0.js:122 X.Ob @ firebase.2.4.0.js:259 s @ app.js?1494260277:44 (anonymous) @ app.js?1494260277:44 (anonymous) @ base.js?1492617404:1 app.js?1494260277:31 Timeout ref showed error! app.js?1494260277:31 Firebase Online
1494732970

Edited 1494734020
I suppose the keep functions are especially resource-intensive... I've brought your report to the attention of the Devs. In the meanwhile, here's another macro that should do most of what you'd like: /r 1d[[ 3 + d3=3 * (1 + d4=4 * (2 + d6=6 * (2 + d8=8 * (2 + d10=10 * (2 + d12=12 * (2 + d20=20 * 8)))))) ]] You would have to mentally compare the exploded die roll to the maximum of the previous die.
1495146793
Gid
Roll20 Team
I don't know if this is occurring or not, but there is a finite ceiling to how many nesting elements that can occur within an inline rolls (99). Something this robust could be beyond the scope of Roll20's in-the-box macro system and where one may need to switch over to using API scripting instead.
1495158714

Edited 1495158953
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I managed to simplify the expressions for the die rolls enough that they resolve within a reasonable amount of time. The d4 expression now takes about 8 seconds to resolve, but that's acceptable enough without requiring the sheet users to have access to the API system.
1495161607

Edited 1495161621
If you replace any instances of 1d0 with {0}, you should be able to reduce the amount of time further.
1495221794
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Silvyre said: If you replace any instances of 1d0 with {0}, you should be able to reduce the amount of time further. Thanks, I just tried that out and it now only takes about 5 seconds to resolve for the d4 expression. Every second helps! :)