## Exploding Dice

General program usage, discussion on writing generators for IPad Pro.

### Exploding Dice

I'm working on a roller for the BASH! RPG, and I've come up against a problem.

When doubles are rolled in BASH, dice explode - if the two d6s you're rolling match, roll another d6 and add it to the result, and, if THAT d6 either result, roll again etc.

So this is the code I have so far:

Code: Select all
`Table: BASH RollSet: var1 ={1d6}Set: var2 ={1d6}Set: var3 ={1d6}Define: vart ={!{\$var1}+{\$var2}}##vart = total of roll so farSet: vart =[when] {\$var1} = {\$var2} [do] {{\$vart}+{\$var3}}[end]##if doubles are rolled, add var3Total of {\$vart} ({\$var1},{\$var2},{\$var3}##Print stuff out for debugging purposes)`

The variable "vart" is supposed to contain the total of the rolls. Only, the [when] statement doesn't seem to work - it's not comparing var1 and var2 properly, and it's not adding var3 to them if they are equal. Additionally, the output is all messed up, viz:
Code: Select all
`Total of  0 (5,5,1Total of  0 (6,6,3Total of  0 (2,2,6Total of  (6,3,2Total of  (2,3,4Total of  (6,1,2Total of  0 (3,3,2Total of  (6,3,6Total of  0 (1,1,2Total of  (1,5,4Total of  (4,3,2`

I can't help but feel it's a syntax problem, but I can't figure it out.
tog23
Torch Bearer

Posts: 4
Joined: Tue Apr 10, 2012 8:45 pm