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

how to simulate a look up table

I have a system that rolls a d4 when the input is 1, d6 when the input is 2, d10 when the input is 3, and d20 for everything higher. The input ranges from 1-20, any suggestions for how to simulate this?
1489525864
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
What do you mean by input? Is it based on a random die roll, or an attribute on your character?
roll query, the character has a number of resources they can make use of and depending on how much they use it rolls a different die. I have a table they can look at but if they don't have to reference another document all the better.
1489526704

Edited 1489526775
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
ah, so they choose, and input the number, great, that should be pretty doable. Something like: [[ [[{?{Resources},0}=1]]d4+[[{?{Resources},0}=2]]d6+[[{?{Resources},0}=3]]d10+[[{?{Resources},0}>4]]d20]] Should do what you want -Scott All credit to Silvyre, as I adapted this from one of his macros for one of the 5e sheets.
As ugly as this is you probably will need the whole thing to make sense of this question, so here is the full macro: @{character_name} uses [[?{Alar amount}]] Alar to draw up to [[?{Alar amount}*(?{Alar amount}-1)+4]] Au of energy from the source and apply up to [[ [[{?{Alar amount},0}=1]]d4 + [[{?{Alar amount},0}=2]]d6 + [[{?{Alar amount},0}=3]]d10 + { [[ [[ ceil((?{Alar amount}*?{Alar amount}-?{Alar amount}+4)/20)*{?{Alar amount},0}>4]]d20]],  [[?{Alar amount}*(?{Alar amount} -1)+4]] }kl1]] Au of energy to the target. So in it's current form the chat output is perfect and it functions exactly as I would expect. The only problem is that the d20's never roll on screen. If I remove the last set of square brackets then it will roll the d20's on screen and the chat looks like this: [[ 0d4 + 0d6 + 0d10 + { 16, 16 }kl1 As well as not rolling for any of the low values with an output that looks like this: [[ 1d4 + 0d6 + 0d10 + { 0, 4 }kl1
1489533418

Edited 1489533490
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Matthew K. said: As ugly as this is you probably will need the whole thing to make sense of this question, so here is the full macro: @{character_name} uses [[?{Alar amount}]] Alar to draw up to [[?{Alar amount}*(?{Alar amount}-1)+4]] Au of energy from the source and apply up to [[ [[{?{Alar amount},0}=1]]d4 + [[{?{Alar amount},0}=2]]d6 + [[{?{Alar amount},0}=3]]d10 + { [[ [[ ceil((?{Alar amount}*?{Alar amount}-?{Alar amount}+4)/20)*{?{Alar amount},0}>4]]d20]],  [[?{Alar amount}*(?{Alar amount} -1)+4]] }kl1]] Au of energy to the target. So in it's current form the chat output is perfect and it functions exactly as I would expect. The only problem is that the d20's never roll on screen. If I remove the last set of square brackets then it will roll the d20's on screen and the chat looks like this By "not rolling the d20's", do you mean it doesn't roll the 3d dice? This is because 3d dice are only rolled for the top level of nested inline rolls, so [[1d20]] will roll in 3d, [[ [[1d20]] +3]] will not. [[ 0d4 + 0d6 + 0d10 + { 16, 16 }kl1 As well as not rolling for any of the low values with an output that looks like this: [[ 1d4 + 0d6 + 0d10 + { 0, 4 }kl1 This is because the inline roll is not complete.
Figured out what I was doing wrong. In order to see the d20 rolls I had to remove the "[[ ]]" around it but doing so made my group roll of "{dice, value}kl1" fail, once I put a pair of "{ }" around the value the output came out correct and I can see the dice rolling. That was really hard to see, thanks for helping me pick it apart.
1489539539
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
glad it's working