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

Attribute Command Buttons

December 31 (4 years ago)

Hello, I'm new to all these macros. I've tried to search this problem on google but haven't found a solution that works. 

I want to create an ability command button that calls on an attribute in the sheet. I'm currently using the 5e character sheet. I currently have tried doing this:

/w gm &{template:default} {{name=Character's Proficiency}} {{Proficient Skills=[History](~{character|history_roll})}}

I currently get the error "No ability was found for %{{character|history_roll}"

I want to create a macro that displays all the character's proficiency as buttons but nothing seems to be working. The macro seems to be only looking for abilities but not attributes. When I put a @ in front of the {character|history_roll} it seems to break the macro. I'm not a pro user so I can't use API scripts, is this problem solvable without the use of API scripts?

December 31 (4 years ago)
Jordan C.
Pro
API Scripter

There's some funky escaping for attribute calls within a button; the "~character ... " calls abilities. To do attributes you need to call them with the @ symbol but escape it after an exclamation point, to make it a chat command, and vertical tab escape (couldn't tell you why). So the inside of the button will start something like this

(!
@

From there you can do what you want. The history button would look like this where "character_name" can be changed to selected or an ID if needed:

[History](!
@{character_name|history_roll})
December 31 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Due to the complexity added by features that affect the roll, such as Reliable Skill, the sheet does a lot of pre-calculating, and produces the appropriate roll as an attribute, not an ability. This makes them hard to use in chat menus, and pretty much impossible in drop down queries. This is due to the Order of Operations, which expands attribute calls before doing anything else. So what looks to you like:

[History](@{character|history_roll}

actually resolves in chat as

[History](@{wtype}&{template:simple} {{rname=^{history-u}}} {{mod=@{history_bonus}}} {{r1=[[@{d20}+1[intelligence]@{pbd_safe}]]}} {{always=1}} {{r2=[[1d20+1[intelligence]@{pbd_safe}]]}} {{global=@{global_skill_mod}}} @{charname_output})

... which will produce garbage.


Jordan's trick works because it keeps that attribute call from resolving until it is sent separately.

The ! at the beginning ensures that the button works. It thinks this will be an API call, so Roll20 will go ahead and make a button

The 
 is a carriage return, so that the command issued by the button when pressed will put a new line after the exclamation point, as if you had typed "!" and pressed enter, issuing a blank API call.

The @ is the @ symbol, which will only resolve at this point, when the button has been pressed, not when it was created.


Thus, when you send:

[History](!
@{character_name|history_roll})

you create a button, that when pressed will send to chat:

!
@{character_name|history_roll}




As an aside, this is why the button is called an API button, but you don't need the API in order to make use of it. The "!" tricks Roll20 into making an API button, even though an API command is never used.

December 31 (4 years ago)

Thank you so much Jordan! I thought I had tried

!&#13

already, but I must have messed something up along the way. And thanks for the breakdown Keith.

January 01 (4 years ago)

Can't you just do:

[History](~character|history)

for the button inside the macro?
That doesn't require any special symbols (or symbol substitutions). It works for all skill names (with a _ for multi-word ones like sleight_of_hand).
It also works with Ability Checks:

[Dexterity Check](~character|dexterity)

and Saving Throws:

[Constitution Save](~character|constitution_save)


Basically, any roll command built into the sheet can be put into a button with that formula, where if the roll command is X_roll you do it as [Button name](~character|X). You don't need the "_roll" as it's implied in using the typed/button command.

January 01 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

That works in a macro that is built as an Ability on a character sheet. For a macro in the collections tab, you need the other syntax. Karfumble wasn't clear where the command was built. The conversation had steered towards a Collections macro and that code will work in either place. In general, I recommend always building automation into Abilities rather than Macros, though. Obligatory link: Macro Character Sheet

Also Karfumble, you might be able to pull useful info out of this: NPC Statblock Chat Menu for D&D 5e sheet — No API required!

January 01 (4 years ago)

Edited January 01 (4 years ago)

I was building my command in Abilities. Thanks for linking that thread Keith! I wanted to speed up my NPC combat.

January 01 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Cool. Abilities are so much simpler. Be sure to read the last post in the first, closed thread, for Oosh's great addition of how to suppress blank ability reports.