So I made a pretty simple dice roller for my android phone using Tasker. If you don’t know what Tasker is, it’s an all-around automation app. It’s been around for as long as I have been using Android phones I would guess. I’ve used it for years but have gotten really serious about it in the last year or so. This isn’t a post about Tasker though, although you will need it for this.

I had come across a Task (a set of actions) that would allow you to simulate the roll of a single six sided die. Really it’s just a random number from 1-6 so that part is pretty easy to emulate. I wanted to be able to roll multiple dice and I wanted the whole gamut, 2,3,4,6,8,10,12,20 and percentile dice. I took a little bit of work but I was able to get that part finished. I am currently using Google Assistant Intercept so I can say “roll 2d10” and it correctly recognizes that, gets the random number between 2 and 20 in that case, displays it on the screen and also speaks the answer. Tasker steps are below:

```
Task: RPG Dice Roll
<How many dice to roll>
A1: Variable Set [
Name: %Dice_number
To: %par1
Structure Output (JSON, etc): On ]
<What type of dice (d6, d10, d20, etc)>
A2: Variable Set [
Name: %Dice_type
To: %par2
Structure Output (JSON, etc): On ]
<Sets the minimum amount. This is easy, it just matches how many dice you are rolling. The minimum number you'll get>
A3: Variable Set [
Name: %HowManyDice_min
To: %Dice_number
Structure Output (JSON, etc): On ]
<The rest of the Variable sets puts the max amount you can roll * whatever kind of dice it is, i.e. 3d12 would be 12 * 3.>
A4: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 2
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 2 ]
A5: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 3
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 3 ]
A6: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 4
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 4 ]
A7: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 6
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 6 ]
A8: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 8
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 8 ]
A9: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 10
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 10 ]
A10: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 12
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 12 ]
A11: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 20
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 20 ]
A12: Variable Set [
Name: %HowManyDice_max
To: %Dice_number * 100
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
If [ %Dice_type ~ 100 ]
<Found this one at Soundbible. You can download your own sound file or disable this part.>
A13: Music Play [
File: Tasker/soundfiles/Shake And Roll Dice.wav.crdownload
Start: 0
Stream: 3 ]
<Get the random number between the minimum # set earlier and the max # set earlier and outputs it to the Dice variable.>
A14: Variable Randomize [
Name: %Dice
Min: %HowManyDice_min
Max: %HowManyDice_max ]
A15: Say [
Text: You rolled a %Dice
Engine:Voice: default:default
Stream: 3
Pitch: 5
Speed: 5
Respect Audio Focus: On ]
A16: Flash [
Text: <h1><b><center>%Dice</center></b></h1>
Long: On
Tasker Layout: On
Title: You Rolled a:
Continue Task Immediately: On
Dismiss On Click: On
Show Over Everything: On
Position: Top
Use HTML: On ]
```

I do have this up on Taskernet as well, you can find it here if you don’t want to input all of that. I would also like to create a series of scenes for this as well at some point but I’m pretty shitty at drawing. I’m thinking animated gifs that show up with the correct number and type of dice and actually show the correct numbers on them. Seems like it would be pretty difficult to implement and would need to include hundreds of images to make it work right. IDK. Going to have to think about that one for a while. I tried using DALL-E and LeapAI to create the images on the fly but it didn’t work worth a crap. Vaguely resembled dice but the background wasn’t transparent and the numbers on them weren’t actually numbers.

## Leave a Reply