Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Brackets in brackets in brackets - template nesting Inception

Hey all, I've lost my mind and decided to create treasure generating macros based on the DMG. I've got simple case like the 0-4 CR ones working, but there is some tricksie concatenation going on with the CR 5-10 where it comes up with "150 cp and 40 ep" type of thing. The math output is correct, but I'm showing the rolls as well: &{template:default} {{name=Treasure for CR 5-10, 1-30}} {{Total= [[ [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 ]]cp and [[[[1d6]]*10]] ep}} {{Dice= $[[0]] $[[1]] $[[2]] $[[3]] $[[4]] }} which shows up as That pesky tag-along ep value is rolled, but the dice display doesn't actually work. I've added and subtracted brackets, and moved things higglety-pigglety, but I'm wondering if maybe that level of nesting just isn't supported? Can anyone point out my error or confirm that the reference to the dice rolls will break when the nesting is concatenated with the text? Any helpful pointers appreciated, M
1609130258
GiGs
Pro
Sheet Author
API Scripter
Can you explain what exactly isnt working? What is wrong with the display? If you want that 120 on the second row to be the ep dice, you have to change the $number. So the dice section would be {{Dice= $[[0]] $[[1]] $[[2]] $[[3]] $[[5]] }}
GiGs, That was exactly what I was going for. Why does that need to be incremented? (Pointing to a post with details is totally fine, I just want to understand why it would be the case.) Thanks for the insight! M
1609135028

Edited 1609135109
Markie said: GiGs, That was exactly what I was going for. Why does that need to be incremented? (Pointing to a post with details is totally fine, I just want to understand why it would be the case.) Thanks for the insight! You have to count each double set of closing braces.  $[[4]] corresponds to the 4th die roll in bold here: {{Total= [[ [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 ]] cp and [[[[1d6]]*10]] ep}} You could also display $[[6]] for the last roll that is made. You can test that for yourself with this: /w gm &{template:default} {{name=Treasure for CR 5-10, 1-30}} {{Total= [[ [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 ]]cp and [[[[1d6]]*10]] ep}} {{Dice= $[[0]] $[[1]] $[[2]] $[[3]] $[[4]] $[[5]] $[[6]]}} $[[4]] Corresponds to the braces outside of rolls #0, #1, #2, & #3; and $[[6] corresponds to the braces outside of roll #5 * 10. 
1609136197
GiGs
Pro
Sheet Author
API Scripter
Markie said: GiGs, That was exactly what I was going for. Why does that need to be incremented? (Pointing to a post with details is totally fine, I just want to understand why it would be the case.) Thanks for the insight! M When using this syntax $[[0]] $[[1]] etc, you are incrementing through the inline rolls in the roll, with 0 being the first.  In this set: [[ [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 + [[1d6]]*10 ]] 0, 1, 2, 3 arethe individual dice, but 4 is the total: the outer set of inline roll brackets.  That is followed by this [[[[1d6]]*10]] Here, the inner [[1d6]] is roll 5, and the total [[ 1d6*10]] is roll 6. So when you have nested inline rolls, you count the inner rolls first from left to right, but then count the outer rolls. If you had something like this: [[ [[ [[1d6]] *10 ]] *10]] [[1d10]] then $[[0]] would represent the 1d6 roll, $[[1]] would represent 1d6*10, and $[[2]]  would represent 1d6 * 100. And then $[[3]] would represent the d10 roll.
Aha! My mind was finding the break between the sets of rolls, but didn't get the connection to the total versus each of the component rolls. Thank you both for all your assistance, and continued sharing of wisdom. Much appreciated! M