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

Trying to add Button for crit into Template

1598764856

Edited 1598765511
Hello, I'm not entirely sure this is the place to post, so I apologize if it's not. I'm trying to add a button at the bottom on the Attack rolls from the abilities for a custom game and sheet. So this is the roll(this part works just perfectly): &{template:default} {{name=Targeting}} {{Attack=[[1d20+@{Response}}+?{Assist Bonus|0}]]}} {{Damage=[[1d12+@{Firepower}?{Roll As: |Mau, +0|Panther, +0|Alt, +0}]]}} I wanted to add a button at the bottom or after this that the players can click if they roll a crit on the "attack". So, I think either this cannot work (very likely) altogether, or I just don't understand the button functions/limitations(more likely). This is what I tried adding (in various places because my "coding" is trial and error lol): [Crit](~Mau|[[roll=1d12+@{Firepower}]]) Is this possible and I'm just not using it right? I would like for it to go with the "ability roll" and draw from attributes to just roll the damage dice again without making players have to clutter the chat with multiple template rolls. And is there a way to have it auto calculate? My only other thought as a solution is to add "Critical" as an ability that uses: &{template:default} {{name=Critical}} {{Added Damage=[[1d12+?{Which attack?|Gun,{@Firepower}|Slash,{@Melee}]]}}  And then manually calculate the total. 
1598767122
GiGs
Pro
Sheet Author
API Scripter
You cant put rolls directly in a button like that. You need to create an ability on the sheet, and put the call for that ability in the button. If its a custom sheet, the ability can be a button in the sheet code, hidden by CSS. Your Critical ability has the brackets messed up - should be @{Firepower} not {@Firepower}. If you create that critical ability, your button can be [Crit](~Mau|Critical)
1598768031

Edited 1598768551
So would this be able to add the critical dmg to the previous roll? Or is there something completely different. The only post I could find is so old templates don't even work the same anymore (it's like 7yrs old) and it seems to always roll crit damage. Because if I add crit as an ability, then there's no need for a button that won't appear in the template if they can just click the button with a query and then manually add it anyway.  I just want it simpler than "Reroll the dice and add it" every time players get a crit. I used templates so that the rolls could be differentiated from each other which is beautiful. If I can't get a crit system working, it's not the end of the world, but it's possible on the premade sheets - my other fear is I'm not Pro so maybe it's only available if I pay (I would if I could, but sadly I cannot.) And thank you for the response GiGs! EDIT: I got the button to work on the template, using "Critical" as an ability as suggested and it rolls the damage with the query prompt. Honestly, think I can live with that, and try to find a way to hide the Critical ability (which I doubt I can do, but who knows. It's fun to fiddle with).
1598769086
GiGs
Pro
Sheet Author
API Scripter
Abbie G. said: So would this be able to add the critical dmg to the previous roll?  This isnt something you can do, usually, without the API. There is a way to do it, but only if you aren't using the turn timer for initiative, and it's fairly complex to set up. If the button roll is working, its easier to use that. EDIT: I got the button to work on the template, using "Critical" as an ability as suggested and it rolls the damage with the query prompt. Honestly, think I can live with that, and try to find a way to hide the Critical ability (which I doubt I can do, but who knows. It's fun to fiddle with). To hide the button, it's a two-step task. First, add a class to the button code like this:how to do it. <button type="roll" name="roll_critical" class="hide" value="whatever"> The class is the important part. Add that to your button. Then in the CSS for your sheet add this: button.sheet-hide {      display:none; } That should hide it.
1598770496

Edited 1598770583
Oosh
Sheet Author
API Scripter
You can do something hacky with the roll system: &{template:default} {{name=Weapon Attack}} [[ [[floor( ([[1d20+?{Response|4}[RES]+?{Assist Bonus|0}[ASST]]]-?{Response}-?{Assist Bonus}) /20)]]*[[1d12 + ?{Firepower|5}[FIRE] ]][CRIT] ]] {{Attack Roll=$[[0]]}} {{Damage=[[1d12+?{Firepower}[FIRE]]] + $[[3]] crit}} If you can put up with the 0 crit damage being rolled all the time when there is no crit. I've changed a couple of the Attribute calls to Queries just for testing - I assumed a crit was only on a 20. This also obscures the 3d roll for the d20 - if that's important to you, this method probably isn't much good.
1598785087
Andreas J.
Forum Champion
Sheet Author
Translator
look at the 5e sheet's code for how it does things.
1598819644

Edited 1598838092
GiGs said: EDIT: I got the button to work on the template, using "Critical" as an ability as suggested and it rolls the damage with the query prompt. Honestly, think I can live with that, and try to find a way to hide the Critical ability (which I doubt I can do, but who knows. It's fun to fiddle with). To hide the button, it's a two-step task. First, add a class to the button code like this:how to do it. <button type="roll" name="roll_critical" class="hide" value="whatever"> The class is the important part. Add that to your button. Then in the CSS for your sheet add this: button.sheet-hide {      display:none; } That should hide it. I don't want to hide the button, I was more trying to hide the actual ability from the character sheet - I don't mind the crit button being there in every role. Also, I'm not "Sheet Author" or "Pro" so I don't have access to CSS, and I'm using the Ability rolls with macros that are typed when the roll is clicked to do most of this. Which, is the only reason I want to hide the Crit ability so it's not another roll on the sheet. (It's a custom setup for a homebrew game, so there's a lot and I'm just trying to limit roll confusion by giving them names and to attempt a declutter of the character sheet as much as I can.)
Oosh said: You can do something hacky with the roll system: &{template:default} {{name=Weapon Attack}} [[ [[floor( ([[1d20+?{Response|4}[RES]+?{Assist Bonus|0}[ASST]]]-?{Response}-?{Assist Bonus}) /20)]]*[[1d12 + ?{Firepower|5}[FIRE] ]][CRIT] ]] {{Attack Roll=$[[0]]}} {{Damage=[[1d12+?{Firepower}[FIRE]]] + $[[3]] crit}} If you can put up with the 0 crit damage being rolled all the time when there is no crit. I've changed a couple of the Attribute calls to Queries just for testing - I assumed a crit was only on a 20. This also obscures the 3d roll for the d20 - if that's important to you, this method probably isn't much good. Okay, I think get some of this - I'm so new to this "coding" it's not funny. "$"/"floor" - I don't know. And I forgot that crit doesn't use modifiers, so I can remove attribute calls in that respect. And if the button is clicked while put inline like this, does it roll within the same template or pull another prompt (like it is as I have it set up)? fine if it does, but I'm having fun learning. So thank you!!!