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

Roll template inside chat button inside roll template

I am trying to create a roll template that contains a chat button that, when clicked will output to a roll template. What I have so far: {{#rollGreater() netSkill -1}}     <div>         {{#rollLess() positive 0}}             Result: {{positive}} [Critical failure](!
&{template:default}{{test=test}}).         {{/rollLess() positive 0}}     </div> {{/rollGreater() netSkill -1}}  The problem seems to be the colon. If I use template:default,  the button doesn't display. If I step it down to template:default it still doesn't display. Likewise with :. If I step all the way down to :, then the button displays correctly, but it doesn't do anything.
1632963808
GiGs
Pro
Sheet Author
API Scripter
If its in a character sheet, put the code for the button in an attribute on the sheet, hide it, then call it in the rolltemplate. You dont need all the character replacements that way.
My intent is to have a button that makes a roll to hit. That roll generates a number of successes between -9 and +9. If the number is positive, it would then roll that many damage dice and select the highest one. I can't see any way to include the damage roll, since it depends on the outcome of the to hit roll, but it seems like I should be able to have it output a chat button which, when clicked, will roll the damage. I can't actually get it to work, however. So a command like &{template:skillRoll}{{result=3t[d-3]}}{{damageDie=8}} would generate a result like 3 successes. Roll Damage If you then clicked on " Roll Damage " it would roll 3d8k1. I can get all that to work fine, but I want the damage roll to output to a roll template, and that is the part that doesn't seem to work.
Maybe something like this? [click me](!%NEWLINE%&{template:default} {{name=tests}} {{are=fun}}) Template in a template: &{template:default} {{name=test}} {{button=[click me](!%NEWLINE%&{template:default} {{name=tests}} {{are=fun}})}}
1633039057

Edited 1633039225
GiGs
Pro
Sheet Author
API Scripter
Randall S. said: My intent is to have a button that makes a roll to hit. That roll generates a number of successes between -9 and +9. If the number is positive, it would then roll that many damage dice and select the highest one. I can't see any way to include the damage roll, since it depends on the outcome of the to hit roll, but it seems like I should be able to have it output a chat button which, when clicked, will roll the damage. I can't actually get it to work, however. So a command like &{template:skillRoll}{{result=3t[d-3]}}{{damageDie=8}} would generate a result like 3 successes. Roll Damage If you then clicked on " Roll Damage " it would roll 3d8k1. I can get all that to work fine, but I want the damage roll to output to a roll template, and that is the part that doesn't seem to work. A rolltemplate can only use numbers if they are forced to become numbers, like so: &{template:skillRoll}{{result=[[3t[d-3]]]}}{{damageDie=[[8]]}} You have a call to a rollable table there, so if you are willing to create tables, just create the macros you need and call those. You don't have to do everything in the sheet. I'm not really a fan of trying to embed everything in one line of code - the api command button system is meant to work with existing macros and abilities, why not create them? That said, roll20 macros cant save values and reuse them in following rolls, so it seems like what you're asking for isnt really possible with the approach you're using or the method I'm suggesting. For this kind of thing you normally need the API, but it is probably possible to use the new startroll system to do what you need. But I'm only seeing a fraction of your code and what you're trying to do here, so wouldn't know where to start.
Looking at the startroll, it seems likely that it will work
Here's a simpler scenario that covers the idea. Let's say I want to roll a d6-3. If the result is greater than zero, then I want to roll that many d4. Could this be done with startroll?