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

API chat buttons won't work

Hello, i am trying to make a Toll of the Dead macro that gives me two buttons. Since the damage differs whether the target is damaged or not. I have searched for a couple of hours now around on roll20 and the macro wiki and there is one fundamental difference that seems to work for others but not me. I really hope you can solve my problem  Here is the Main Macro &{template:default} {{name=Toll the Dead}} {{DC@{spell_save_dc} wisdom saving throw}} {{[Undamaged](~Undamaged) [Damaged](~Damaged)}} Here is Undamaged &{template:default} {{name=Damaged}} {{Damage = [[((@{level} + 1) / 6 + 0.5)d8]] *Necrotic*}} and pretty much the same with Damaged &{template:default} {{name=Damaged}} {{Damage = [[((@{level} + 1) / 6 + 0.5)d12]] *Necrotic*}} Not matter what i do, it always give me this  TypeError: Cannot read property 'substring' of undefined And yes, i have tried just to do [[1d8]] and [[1d12]], but i do want it to update with levels, so I dont have to constantly change the macro whenever i reach the level.
1546382350
The Aaron
Pro
API Scripter
Those are not API Command Buttons, they are Ability Command Buttons. API Command Buttons would have a ! as the first character.  What you are missing is a reference to the character to call Undamaged and Damaged on. The format is something like ~SOME_ID|SOME_ABILITY.  If you’re using macros, you’d need to do a hack with API Command Buttons, something like this: [Undamaged](!
#Undamaged)
Ah, that helped. I assumed the SOME_ID was the character name. I have seen that reference in the wiki before but for some reason it never worked. Thank you very much
1546385920
The Aaron
Pro
API Scripter
Did that fix it?  It should work with either the character name, or the character ID.  Sometimes the character ID is easier as names change, but character ids don't (unless you run them through the character vault).
where do i find character id? I just put in the character name and it worked
i even upgaded it to dmg template instead of default. Unfortunately i dont know how to make the pink buttons look like a regular OGL 5e character sheet attack text. And I also dont know how to put the macro into the character sheet where the Attack and Spellcasting for all the attacks that the character can do is. If you know how to do that, then everything would be perfect :)
1546388732
The Aaron
Pro
API Scripter
You can get the character id from a token that represents it by selecting it and running: @{selected|character_id} or with the character name like: @{Bob the Slayer|character_id} The token route is often easier. Good question on the attacks and spells.  I know it's possible, but I don't use the OGL, so I don't know how off the top of my head.  There are two things at work here. 1) Getting it to look like the right buttons: This is a matter of having the link in the right place in the OGL Roll Template.  I don't know precisely what that looks like, but if you execute something from the sheet that is a good example of how you want it to look, you can push up in the chat command box and get the output that was sent, then find the thing that looked right and extrapolate.  It will begin with a different template, something like &{template:5eogl}{{ ... }} or some such. 2) Getting the right link: Do the above with something that gives you a link. A good example is when you have the roll and damage separate such that you check the roll of an attack first, then click something to make it show the damage.  (I'm 99% sure Steve added the [label](~ID|Action) syntax explicitly to be able to do this.)  That should give you an idea of how to reference an ability that is on the character sheet.  It will have something to do with the repeating row id, and probably depends a bit on the internal caching of ability commands.  The best I can say to that is "Good luck!" Hope that helps.
1546422409
Finderski
Plus
Sheet Author
Compendium Curator
The Aaron said: Good question on the attacks and spells.  I know it's possible, but I don't use the OGL, so I don't know how off the top of my head.  There are two things at work here. 1) Getting it to look like the right buttons: This is a matter of having the link in the right place in the OGL Roll Template.  I don't know precisely what that looks like, but if you execute something from the sheet that is a good example of how you want it to look, you can push up in the chat command box and get the output that was sent, then find the thing that looked right and extrapolate.  It will begin with a different template, something like &{template:5eogl}{{ ... }} or some such. 2) Getting the right link: Do the above with something that gives you a link. A good example is when you have the roll and damage separate such that you check the roll of an attack first, then click something to make it show the damage.  (I'm 99% sure Steve added the [label](~ID|Action) syntax explicitly to be able to do this.)  That should give you an idea of how to reference an ability that is on the character sheet.  It will have something to do with the repeating row id, and probably depends a bit on the internal caching of ability commands.  The best I can say to that is "Good luck!" Hope that helps. Ability commands are part of the roll template CSS.  You'd need to use a roll template that has the button formatting you like.  For example, the sheet I'm working, to get the Ability Command buttons to not be pink I had to add this to the roll template CSS: .sheet-rolltemplate-roll .sheet-templateButton > a[href^="~"], .sheet-rolltemplate-damage .sheet-templateButton > a[href^="~"] {     background-color: #900C3F;     font-weight: bold; } And the Roll Template HTML: {{#button}} <div class="sheet-templateButton"> {{DmgRoll}} </div> {{/button}} So, you'll need to find the template that has the appropriate CSS and you'll also want to check if there's a special way you need to call the template for the button to be included with the proper formatting... You may need to look on GitHub and check out the HTML and CSS code for the sheet.  The easies way to sift through it would be search in the CSS for [href^ to find the class(es) where the button style is defined. and then search the HTML for the class to see how it's used.
1546423052
Finderski
Plus
Sheet Author
Compendium Curator
So, I did a quick look at the CSS and the HTML for the 5e OGL sheet...the roll templates that have the CSS coding to modify how the ability command buttons look are: atk and npcatk. The roll template piece that calls the ability command buttons are: rname and rnamec CSS: .sheet-rolltemplate-atk a[href^="~"] {     background-color: transparent;     padding: 0px;     color: black;     border: 0px; } .sheet-rolltemplate-atk a:hover {     color: #EC2127; } .sheet-rolltemplate-atk a[href^="~"]:visited {     pointer-events: none; } .sheet-rolltemplate-npcatk a[href^="~"] {     background-color: transparent;     padding: 0px;     color: black;     border: 0px; } .sheet-rolltemplate-npcatk .sheet-header a[href^="~"] {     color: rgb(126, 45, 64); } .sheet-rolltemplate-npcatk a[href^="~"]:hover {     color: #EC2127; } An example of the Ability Command button being called in a roll template: {{rname=[@{name}](~repeating_npcaction-l_npc_dmg)}} {{rnamec=[@{name}](~repeating_npcaction-l_npc_crit)}} Hope this helps.