From 1e24a63cad48202b873c650116ed870c8921e4f8 Mon Sep 17 00:00:00 2001
From: Malin Freeborn <malinfreeborn@posteo.net>
Date: Tue, 15 Aug 2023 22:28:10 +0200
Subject: [PATCH] make dlist environment

---
 docs.tex   | 11 +++++++++++
 layout.sty | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/docs.tex b/docs.tex
index 8d1bc46f..21e1806a 100644
--- a/docs.tex
+++ b/docs.tex
@@ -122,6 +122,17 @@ Then we have \verb"\begin{exampletext}" for example:
 
 \end{boxtext}
 
+\subsubsection{Showing Dice}
+
+You can show dice with \verb"\dicef{7}", which shows up as `\dicef{7}'.
+And you can list dice, with results, with the `\texttt{dlist}' environment.
+
+\begin{dlist}
+  \item Badger
+  \item Fox
+  \item Gazebo
+\end{dlist}
+
 \subsection{Magic}
 
 \subsubsection{Magical Items}
diff --git a/layout.sty b/layout.sty
index d6c6929a..6c878377 100644
--- a/layout.sty
+++ b/layout.sty
@@ -322,6 +322,24 @@ bookmarks=true]%
   \label{#2}
 }
 
+\newcommand\dicef[1]{%
+  \setcounter{track}{#1}%
+  \ifnum\value{track}>0%
+    \whileboolexpr{%
+      test {\ifnumcomp{\value{track}}{>}{6}}%
+      }{%
+        \addtocounter{track}{-5}%
+        \epsdice{5}%
+      }%
+    \epsdice{\value{track}}
+  \else%
+    \arabic{track}%
+  \fi%
+}
+
+\newenvironment{dlist}%
+  {\begin{list}{\Large\dicef{\value{list}}}{\usecounter{list}}}%
+  {\end{list}}%
 
 \newcounter{blingNo}
 \setcounter{blingNo}{0}
-- 
GitLab