Rolisteam / DiceParser

Powerful dice Roller is used as discord bot, irc bot, cli tool and inside Rolisteam : 1d20+4, 1L[head,arm,leg,belly,chest], 1d6+1d8, 8+5*3
http://www.rolisteam.org/
GNU General Public License v3.0
125 stars 31 forks source link

Request: Expand Functionality in $x to allow specifing number of digits for output #36

Closed Forekast closed 5 years ago

Forekast commented 5 years ago

This is mostly in reaction to wanting better control over spacing in the outputs. I will use my exact use-case as an example for this request:

I would like to be able to use this format !4d6k3;4d6k3;4d6k3;4d6k3;4d6k3;4d6k3;"[$1, $2, $3, $4, $5, $6]" But with the ability to specify # of digits in the output. i.e. if $1 is 8, $1{2} would produce 08, allowing each item to be the same number of digits.

I'm currently using a work-around to place a '0' in front of a single digit output: !4d6k3;4d6k3;4d6k3;4d6k3;4d6k3;4d6k3;$1i:[<10]{"0$1"}{"$1"};$2i:[<10]{"0$2"}{"$2"};$3i:[<10]{"0$3"}{"$3"};$4i:[<10]{"0$4"}{"$4"};$5i:[<10]{"0$5"}{"$5"};$6i:[<10]{"0$6"}{"$6"} Unfortunately, doing it this way this prevents me from formatting my output to look like the example above [XX, XX, XX, XX, XX, XX]

Would it be possible to implement a way to arbitrarily increase the number of digits in an integer output? Perhaps using the aforementioned format of $X{Y} where Y is the number of digits to display

Thank you

obiwankennedy commented 5 years ago

I can do that.