#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Roll four, drop the lowest

edited December 2014
I wanted to add some functionality that would replicate "Roll 4d6, drop the lowest" and make it good and generic. Here's what I came up with:
```Table: Roller
Set: dice={\$1}
Set: reps=&#91;when&#93;{\$2}&gt;0&#91;do&#93;{\$2}&#91;else&#93;0&#91;end&#93;
Set: droplow=&#91;when&#93;{reps}=0&#91;do&#93;{droplow}&#91;else&#93;&#91;when&#93;{\$3}&gt;0&#91;do&#93;&#91;{{\$3}*10+1} &gt;&gt; trim&#93;&#91;else&#93;1&#91;end&#93;&#91;end&#93;
Set: drophigh=&#91;when&#93;{reps}=0&#91;do&#93;{drophigh}&#91;else&#93;&#91;when&#93;{\$4}&gt;0&#91;do&#93;&#91;{{\$4}*10+1} &gt;&gt; trim&#93;&#91;else&#93;1&#91;end&#93;&#91;end&#93;
Set: extraplus=&#91;when&#93;{reps}=0&#91;do&#93;{extraplus}&#91;else&#93;&#91;when&#93;{\$5}&gt;0&#91;do&#93;&#91;{\$5} &gt;&gt; trim&#93;&#91;else&#93;0&#91;end&#93;&#91;end&#93;
&#91;when&#93;{reps}&gt;0&
&#91;do&#93;{&#91;&#91;&#91;@{reps} SubRoller with {dice} &gt;&gt; each Pad &gt;&gt; sort &gt;&gt; implode + &#93; &gt;&gt; reverse &gt;&gt; substr {drophigh} 0 &gt;&gt; reverse&#93; &gt;&gt; substr {droplow} 0&#93;+{extraplus}}&
&#91;else&#93;{{dice}}&
&#91;end&#93;

Table: SubRoller
{{dice}}

&#91;&#91;000000000{\$1} &gt;&gt; reverse&#93; &gt;&gt; substr 1 9 &gt;&gt; reverse&#93;

```

The parameters in order are:
dice - could be "1d6" or "2d8+1" or whatever; note that this is a change from an older version of Roller posted in another thread.
reps - how many times to roll the dice specified in the first parameter
droplow - number of low results to drop before totalling
drophigh - number of high results to drop before totalling
extraplus - amount to add (or possibly subtract) to the final after-dropping total

To get the results I originally wanted:
"Roll 1d6 four times, and drop the single lowest result before adding"

[@Roller with 1d6, 4, 1]

15
16
7
10
10

Something crazy:
"Roll 2d8+1 ten times, drop the two lowest and three highest results and subtract 3 from the total -- and do all that five times"

[@5 Roller with 2d8+1, 10, 2, 3, -3 >> implode]

42, 48, 53, 47, 46
53, 48, 40, 44, 47
37, 55, 55, 44, 48
55, 64, 43, 48, 57
42, 54, 39, 38, 64

More simple:
"Roll 1d10 20 times"

[@10 Roller with 1d10 >> implode]

6, 3, 10, 5, 4, 1, 4, 9, 8, 1
1, 5, 8, 4, 9, 6, 5, 4, 10, 6
5, 9, 5, 8, 5, 6, 8, 3, 10, 4
8, 7, 4, 10, 5, 2, 7, 4, 8, 7

One minor limitation -- if the result of {dice} might be a trillion or more (like 1000d9999999999) the dropper won't produce correct results.

Give it a try, and if you have any questions post it here!

• That is really cool :-)
• Is this the complete roller code? I copied and pasted into a generator and get (Invalid expression: ) as the result.
• Hi chuqa,

Sorry, I guess I skipped a step in my original description. If you just want to see Roller work, add this above all the other code:
```Table: RollerTest
&#91;@Roller with 1d6, 4, 1&#93;
```
• good post but i want some change ......
• Hi ashan, welcome to the forums!

What change would you like to see?
• Very, very nice!
So if you need to roll up a D20 / D&D character it works like this:

Table: D20Attributes
[@6 Roller with 1d6, 4, 1 >> implode]
• Alternon wrote:
Very, very nice!
So if you need to roll up a D20 / D&D character it works like this:

Table: D20Attributes
[@6 Roller with 1d6, 4, 1 >> implode]
You got it! Glad you like it!