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

simple roll script request weighting which dice it will roll

Roll20, I wish to have a macro that rolls either a 1d4, 1d5, or 1d6, weighted to a d4.  I tried [[1d[[1d6min4]] ]] but it seems to always roll a 1. I looked in the Wiki but didn't find anything similar. Any ideas? Thanks
1629309521
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
You mean you want it to roll a die with a random number of sides, with most of them being a d4? What sort of ratio of sides do you want. e.g. for a ratio of d4:d5:d6, should it be 2:1:1, 3:1:1, etc?
Hey Scott C.,  Based on the way you stated your follow-up, my thought would be a six sided dice with three of the sides being 4. So d4, d4, d4, d5, d6.  Does this make sense?
1629310420
The Aaron
Roll20 Production Team
API Scripter
1d6min4 isn't a valid syntax.&nbsp; I have a script called WeightDie that creates Rollable Tables weighted to a particular number, which looks similar.&nbsp; It would generate things like d6min4 which you would use like: [[ 1t[d6min4] ]] Which would have 4 in 6 chance of being 4, 1 in 6 of 5, and 1 in 6 of 6. You could combine that with what you have above like this: [[ 1d[[1t[d6min4] ]] ]] Here's the script:&nbsp;<a href="https://app.roll20.net/forum/post/950142/script-weighted-dice-automated-rollable-table-creation-with-proper-statistical-distribution-for-minimum-rolls" rel="nofollow">https://app.roll20.net/forum/post/950142/script-weighted-dice-automated-rollable-table-creation-with-proper-statistical-distribution-for-minimum-rolls</a>
1629311743
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Barry S. said: Hey Scott C.,&nbsp; Based on the way you stated your follow-up, my thought would be a six sided dice with three of the sides being 4. So d4, d4, d4, d5, d6.&nbsp; Does this make sense? so, that accounts for 5 sides. what about the 6th? Assuming that you wanted 4 sides to be a d4, and then a d5, and a d6, you could use Aaron's script method, or do the following macro: [[1d[[{4d1,1d6}kh1]]]]
Thank you Scott, I can usually follow what the macro is doing, but not this time. 4d1 means it is rolling 4 one sided dice right? How does this create what it does?
Also, thank you Aaron!
1629316660
The Aaron
Roll20 Production Team
API Scripter
Basically 4d1 is the constant 4 in dice format. You can't mix numbers and dice in a { } group, so this lets it work next to the 1d6. The practical upshot is it will be 4 unless the d6 is a 5 or 6. Then that value feeds into the outer roll.&nbsp;
Ah that makes sense. Thank you for the coding lesson!