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

(Request) Help with dice rolling script

Hi! I need help writing a script for a pretty simple dice system, not unlike the exploding die. The core is that when you roll D6, each time you roll a 6, you take that 6, re-roll together with a new d6. For example: 3D6 = 1,3 & 6. Then you keep the 1 & 3, re-roll the 6 together with a new d6 = 2 & 4, with a total of 10. I'm asking for help because I have no idea how to write the script myself (or any script for that matter) I hope somebody can help me.
1397365359

Edited 1397365399
I'm not sure I follow the math. If you roll a 1,3,6 then you roll another d6? The part I'm not understanding is the 're-rolling the 6 together with a new d6 = 2 & 4'. either the total should be 12 (6 + 2 + 4) or 6 (2 + 4).
1397367538
Konrad J.
Pro
API Scripter
3d6=1, 3, 6. A 6 causes the original 6 die to be rerolled along with an extra d6. Then you add them together with the previous 1 and 3 to get a result of 10. You might be able to do that with regular dice mechanics? I'm not up on my dice rolling. A script it would be easy. What happens if on the reroll you roll a 6?
1397368211

Edited 1397368260
@Konrad Ok I see, he gets 10 from the 1+3+2+4.
1397368811

Edited 1397368992
Nicholas G.
KS Backer
I'd assume it can cascade. One way to describe this system would be like normal dice explosions, except that when you explode you add (2d6!-6) to the roll instead of 1d6!. Mathematically, the thing that's interesting about this system is that explosions have (nearly) no effect on the mean since <2d6-6>=1 combined with the bias of only replacing 6's. Instead they seem to mostly serve to randomly increase the standard deviation of the result.
@Nicholas Indeed, I think that is what was originally confusing me. With explosion you should always yield a higher result, however, this could yield a lower result.
Yes this is exactly what I have been looking for as well. Unlimited dice for the Swedish game Eon.
It's for the same game (Eon). I apologize for being confusing, I tried my best but was kinda tired when I posted it. So here goes take 2: Simply speaking, each time you roll a 6 on a D6 roll you replace that die with two new D6 generating a new result between 2-12. If a new 6 is rolled you repeat until no more sixes are rolled. I assume that is a great way to write it. I'll see if I can manage doing that (I'm new at writing scripts but I'll give it a try). ^^
1397401620

Edited 1397401828
Here you go. This will do what you want it to do without any real formatting. You can make it as fancy or simple as you want it. It also does not do any kind of error checking, so you will need to add that in to prevent the script from crashing or players rolling things they shouldn't. !eon ?{Number of Dice to Roll|1} on("chat:message", function(msg) { // Exit if not an api command if (msg.type != "api") return; // Get the API Chat Command var command = msg.content.split(" ")[0]; var numrolls = parseInt(msg.content.split(" ")[1]); if (command == "!eon") { var count = 0; var roll = 0; var output = ""; while (count < numrolls) { roll = randomInteger(6); if (roll === 6) { // Do this numrolls = numrolls + 2; } else { // Do this output = output + " " + roll; } count++; } sendChat(msg.who, output); } });
Please keep me posted. I am interested in seeing the results.
That works great! Thank you so much. ^^
Looks perfect. Now to upgrade the account. Indeed thank you so much.
Do anyone know if there is a possibility to have the script add up the final result and how to go about doing that?
I created a similar dice mechanic for my d8-based home-brew game system that I plan to play-test here on Roll20. The difference being that dice are not added together when rolled. Instead dice are rolled to beat a target number to accumulate successes. So if a character's dice pool included 3 dice (say d8's since my game is d8-based) and the target number was 7, any 7's or 8's rolled would count as successes. However, there are two alterations to the basic mechanic. The first is "revolving dice" which work like exploding dice in other games. When a die shows its maximum value, a success is tallied and the die is rolled again; tallying successes and re-rolling as long as the die continues to roll its maximum value. That function is covered by basic syntax in the Roll20 dice roller. No real issues there. The second alternate mechanic is my game's version of "exploding dice", which are similar to Marcus V.'s mechanic that opened this thread, only using successes rather than mathematical sums. An exploding d8 in my game that rolls an 8 tallies one success, and is then rolled again along with a second d8. If both those d8's roll 8, the player would tally two more successes and roll 4d8, and so on (and if only one of those dice rolled an 8, the result would be one additional success and another re-roll of 2d8). Make sense? Btw, I am also new to the API (became a mentor last month, half of which I spent in the hospital) and relatively new to coding, aside from basic HTML and a little CSS. This week I have been coding character sheets and am just now learning the syntax for macros, etc.