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

Ability Command Buttons (In Chat)

Hey all, Im VERY new to Roll20 and even newer to scripting macros....

I came across the idea of creating Ability Command Buttons in the chat window and like with every other macro I have found attempted to copy and paste the written macro to see if it would work. I know in theory this is possible (or at least it was a few years ago) but I'm not quite sure what I am doing wrong... or if this code is just not written correctly... Any help would be appreciated!!! 


Here is what I found and copied.... 

/w @{selected|character_name} &{template:5eDefault} {{spell=1}} {{title=Cantrip Select}} {{subheader=@{Selected|character_name}}} {{emote=[@{selected|repeating_spellbookCANTRIP_$0_spellname}](~selected|repeating_spellbookCANTRIP_$0_spellcast) [@{selected|repeating_spellbookCANTRIP_$1_spellname}](~selected|repeating_spellbookCANTRIP_$1_spellcast) [@{selected|repeating_spellbookCANTRIP_$2_spellname}](~selected|repeating_spellbookCANTRIP_$2_spellcast) [@{selected|repeating_spellbookCANTRIP_$3_spellname}](~selected|repeating_spellbookCANTRIP_$3_spellcast)}}


The original thread can be found here: https://app.roll20.net/forum/post/3497121/5e-community-spell-macro

April 01 (5 years ago)

Edited April 01 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

I'm not familiar with your sheet, so to eliminate rolltemplate format errors try running this alone in chat:

[@{selected|repeating_spellbookCANTRIP_$0_spellname}](~selected|repeating_spellbookCANTRIP_$0_spellcast) [@{selected|repeating_spellbookCANTRIP_$1_spellname}](~selected|repeating_spellbookCANTRIP_$1_spellcast) [@{selected|repeating_spellbookCANTRIP_$2_spellname}](~selected|repeating_spellbookCANTRIP_$2_spellcast) [@{selected|repeating_spellbookCANTRIP_$3_spellname}](~selected|repeating_spellbookCANTRIP_$3_spellcast)

The structure looks fine to me. Do you get any error in chat? anything about attributes no found?

Also, is the token you are selecting properly connected to a character (the token's represents property set), and does that character have those attributes?

Also, are you using the community sheet, or a different D&D sheet?

April 01 (5 years ago)

Edited April 01 (5 years ago)

I am running the sheet generated by the charactermancer. 

I am getting a: 

No ability was found for %{selected|repeating_spellbookCANTRIP_spellname}

No ability was found for %{selected|repeating_spellbookCANTRIP_spellcast}

It shows up properly as "buttons" in chat but I am assuming im missing something pretty big here. 

From what I understand it should be calling the action from the "spells" section of the character sheet then the subset "cantrips" from there going down the list 0-3.

Are there other macros that I need to create first in order to make this work? 


Edit: the token represents correct character sheet and the character has said attributes (I double checked that thinking maybe I'm dumber than I thought lol)


April 01 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

If you are using the charactermancer, your sheet is likely the D&D 5th Edition by Roll20 sheet, but your macro is formatted for Roll Templates used by the Community sheet. Every sheet uses it's own template(s) for outputting rolls, and every sheet has it's own names for attributes. To duplicate that macro for the Roll20 sheet, try:

/w @{selected|character_name} &{template:npcaction}{{rname=@{Selected|character_name}}}  {{name=Cantrip Select}} {{description=[@{selected|repeating_spell-cantrip_$0_spellname}](!~selected|repeating_spell-cantrip_$0_spell})
[@{selected|repeating_spell-cantrip_$1_spellname}](~selected|repeating_spell-cantrip_$1_spell})
[@{selected|repeating_spell-cantrip_$2_spellname}](~selected|repeating_spell-cantrip_$2_spell})
[@{selected|repeating_spell-cantrip_$3_spellname}](~selected|repeating_spell-cantrip_$3_spell})}}
April 01 (5 years ago)

Edited April 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

There's some terminology and history to understand, and then it will probably make sense. 

Ability Command Buttons are an adaption of API Command Buttons. API Command Buttons are a Button that executes and API Command. (I know that sounds like a tautology, but stick with me!)  Buttons are basically clickable links, like urls on a website.


In Roll20, you create links in chat like this:

[some label](some url)


API Commands have the structure:

!something

An exclamation mark followed by some text (really just about anything). That command and a bunch of context is received by all the API scripts and interpreted to take some actions. 


An API Command Button is basically a link where the URL portion is an API Command:

[some label](!something)

You click the label, it runs the command.


Abilities are a collection of commands that are executed in the context of a Character. The commands can be basically anything you could put in chat.  Abilities are tied to a specific Character, and are (usually) found on the Attributes and Abilities tab of a Character Journal window.  They can be executed either by clicking their button in that window, or by running a chat command like this:

%{some character|some-ability}


Ability Command Buttons are just like links that instead call that ability. Unlike API Commands in buttons, they have a slightly changed syntax (more on that later):

[some label](~some character|some-ability)

Clicking the button then just runs the ability.


The reason for the different syntax is that whole "usually" regarding the location of abilities. What Ability Command Buttons let you call is actually two things: Character Abilities and Character Sheet Rolls.  As far as I know, you can't call Character Sheet Rolls with the %{} syntax, but it probably doesn't matter.


So, in order for an Ability Command Button to work, it needs to be referring to either an Ability or a Roll for a specific Character. If neither of those exist, it won't work. (It probably fails silently, but it might give an error)  In the case of what you've posted, it's looking at the "selected" character.  "selected" refers to the token you have selected on the map, and any character that it represents.  That token needs to represent a character (Double click it, look at the represents field at the top left, see what character is listed. If there's None, choose one and save.), and that Character needs to either have an Ability with that name (check the Attributes and Abilities tab), or have a character sheet with a Roll by that name (that's harder to explain...).  

Based on what is in your example, it's looking for a Roll on a character sheet, probably the old Community DnD5e Sheet, which you're unlikely to be using.  Try making some Abilities and making Ability Command Buttons that call them for experience. Once that makes sense, you can right click a button/link on a Character Sheet and click inspect, then find the name in the HTML source. (Note that if it's a Repeating Section, like a list of spells or attacks, you have to assemble a couple different bits of data, which I don't think I can describe from memory...)


Hopefully that's enough info to get you started!




I think I may be misunderstanding "attributes" - are you specifically talking about in the "attributes & abilities" section? I am so lost! I really want to learn how to do all this correctly though, so much potential!!! 

April 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

(Man, I took way too long to answer that! =D)

KEITH IT WORKS!!!!

and Aaron thank you for breaking it down for me, reading through the forums (where most people already know and understand) can get a bit overwhelming! 

Now to make it work for the rest of the spell levels! 

April 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Awesome!  No problem. 

April 01 (5 years ago)
vÍnce
Pro
Sheet Author


The Aaron said:

(Man, I took way too long to answer that! =D)

I for one am glad you did that.  :-)


April 01 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Yeah, that was a really good breakdown.