From b49619c1107b60f35611c92abbed584834e08a82 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Mon, 8 Dec 2025 09:04:45 -0800 Subject: [PATCH] add d20 dice roller example --- examples/d20.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/d20.sh diff --git a/examples/d20.sh b/examples/d20.sh new file mode 100644 index 0000000..35a58c2 --- /dev/null +++ b/examples/d20.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env shrimp +# usage: dice + +import math only=random +import list only=first +import str only=[replace starts-with?] + +sides = $.args | first +sides ??= 20 + +if sides | starts-with? d: + sides = replace sides //\D// '' +end + +sides = number sides + +echo 'Rolling d$sides...' +random 1 sides | echo \ No newline at end of file