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 Script to Create Abilities Button in Chat?

Is there an API script (or is it even possible) that creates an API command button for each of a character's Abilities macros, but without having to reference the particular abilid? Essentially, I'm trying to figure out a way to reference the macros listed under the Abilities section of a character sheet using a generic macro. So, using this macro would output to chat a list of buttons that I could click based on the token (and its linked character sheet) I have selected. The functionality is exactly the same as creating a macro using a sheet's repeating fields, which I know I can do, but for the Abilities macros. The theoretical macro would look like: %{selected|repeating_abilities_$0_macro}, %{selected|repeating_abilities_$1_macros}, etc. But, obviously, I don't think it's possible to reference the Abilities section's repeating macros. As far as I can tell, there's no way to do it without an API script, or at least my pea-brain hasn't been able to figure it out. If anyone has any info on the topic, that would be appreciated.
1572994664
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I discussed this here , yesterday, but I'll cross post. Not exactly the same issue, but close enough: The problem you will run into is that attacks are listed in Repeating Fields, each one having a number: $0, $1, $2... You can create a macro creates a button that calls an attack, such as: [@{selected|repeating_attack_$0_atkname}](~selected|repeating_attack_$0_attack) You could even make it pretty by putting it into a roll template with other attacks: &{template:npcaction} {{rname=@{selected|character_name}}} {{description=[@{selected|repeating_attack_$0_atkname}](~selected|repeating_attack_$0_attack) [@{selected|repeating_attack_$1_atkname}](~selected|repeating_attack_$1_attack) [@{selected|repeating_attack_$2_atkname}](~selected|repeating_attack_$2_attack) [@{selected|repeating_attack_$3_atkname}](~selected|repeating_attack_$3_attack)}} This would give you a chat menu that lists the first four attacks of a selected token's character as named clickable buttons. The problem would be if the character had 3 or fewer or 5 or more attacks. Too many attacks and you won't see any after the first four. Too few and you will get error message as Roll20 tries to call up nonexistent attacks. You can suppress error messages by adding  &{noerror} to the end of the macro, but you will still see some garbage buttons. Also, because of the way that the OGL sheet is built, PCs use [@{selected|repeating_attack_$0_atkname}](~selected|repeating_attack_$0_attack) and NPCs use [@{selected|repeating_npcaction_$0_name}](~selected|repeating_npcaction_$0_npc_action) so you would need a separate macro for PCs and NPCs. There are some better ways to do it with API scripts, but these are the limitations of bare macros.
1572994750

Edited 1572994803
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Note that there ARE multiple ways of doing this with existing scripts: Universal Chat Menus, MenuMaker and for a slightly different approach, TokenActions. I can supply links if you need more info. Edit: Is there a reason you don't want to use an API script?
1572995073

Edited 1572995383
Well the problem I'm having is that I'm not referencing the repeating fields in a character sheet, such as the 5eShaped or 5e OGL. So, I'm trying to reference the macros I've made in the Abilites section of the Attributes & Abilities tab of every journal entry. Basically, I'm trying to figure out a way for this to work even without the game having a character sheet. The only reason I haven't already tried to use an API script is because I can't write one up myself, I figured it would be faster (and give me fewer headaches) to ask if anyone has an idea first. I'll take a look at those menus, haven't seen those yet. Edit: As for why I want to accomplish this without using a character sheet, I'm using the D&D 3.5e sheet. The default macros aren't exactly to my liking, and I find it much easier just to write the macros in the Abilities tab from scratch rather try to work within the windows of the sheet. Furthermore, the sheet by default doesn't have repeating sections for NPC attacks, so the only other workaround is to add the NPC's attack macros in the PC side of the sheet.
1572995666
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ah, that's a little clearer. I'm not familiar with the 3.5 sheet, but I can see the problem you are up against. This may require some thought, but I suspect it will need a custom API.
1572996668

Edited 1572996677
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi DJ, Menu Maker has a custom repeating abilities functionality that should work for what you want to do. You'll need to record the stats for the weapon/ability/item/etc in the appropriate repeating item, then create a custom repeating ability in menu maker that will get propagated to all valid characters.
I think Menu Maker still requires that I enter information into a character sheet's repeating field, then it creates an Ability macro in the Attributes and Abilities tab of a journal based on that information. However, I'm trying to do the inverse, i.e. manually create an Ability macro in the Attributes and Abilities tab then reference that list of Ability macros and send them to chat. One thing I could do without an API script is to create the macros first, then create a 3rd macro that uses each of the previous' macroids to create buttons for them, but that just means I have to create yet another macro to accomplish this. Something like: /w gm &{template:DnD35StdRoll} {{name=@{selected|token_name}, Macros}} {{skillflag=true}} {{notes=[Claw +9 melee (1d6+6)](~selected|-Lr0xK3SQjpCIoI-PCIN),  [2 claws +9 melee (1d6+6) and bite +4 melee (1d6+3)](~selected|-Lr0xS8-c9Gvxl8wZK4Q)}} But, essentially I'm trying to omit the macroid (e.g. "-Lr0xS8-c9Gvxl8wZK4Q") so that the macro would look more like [Button](~selected|repeating_abilities_$0_macro) or something, but obviously that doesn't work, hence this thread. If it's possible to find the name of the repeating section of the Abilities column of the Attributes & Abilities tab, I haven't been able to figure it out. That's really my problem: I have no idea the section name for Attributes & Abilities macros. Given that I can't find any information about this since before character sheets were released, I have a feeling that you can't reference the repeating Attributes & Abilities macros like you can with character sheet macros, or at least not without a script.
1573000754
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
To my knowledge, the Attributes and Abilities tab cannot create repeating abilities. They are a list of separate abilities. If I'm wrong, that would be great, because then UCM and MM would become that much more powerful, You could name your abilities A01, A02, A03, and so on. Then create Attributes called A01, A02, A03, and so on. In the abilities you would put the macro code, in the attributes you could put the name of the ability "Sword", "Claw", "Bite" etc. If every NPC had five of these, filled or not, you could then make a universal macro that looks something like: /w gm &{template:DnD35StdRoll} {{name=@{selected|token_name}, Macros}} {{skillflag=true}} {{notes=[@{selected|A01}](~selected|A01) {selected|A02}](~selected|A02) {selected|A03}](~selected|A03) {selected|A04}](~selected|A04) {selected|A05}](~selected|A05)}} I haven't tested it, but it should work in theory.
Yeah I thought about doing that, but the problem would be that I wouldn't know what the content of the macro is until I used it, since each NPC's attacks would be different from each other. It definitely works, but isn't what I had in mind. At this point, it might be easier to add a repeating attack section in the 3.5 sheet itself and just use that like a normal person. Only problem then is that I'd have to create two different macros, one for NPCs and one for PCs. Thanks for the help, at least I'm not insane.
1573004920
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
DJ M. said: Yeah I thought about doing that, but the problem would be that I wouldn't know what the content of the macro is until I used it, since each NPC's attacks would be different from each other. It definitely works, but isn't what I had in mind. At this point, it might be easier to add a repeating attack section in the 3.5 sheet itself and just use that like a normal person. Only problem then is that I'd have to create two different macros, one for NPCs and one for PCs. Thanks for the help, at least I'm not insane. That's why I suggested using Attributes for the button names. The master macro would pick up the button name from Attribute "A01", and the code from Ability "A01". As for the other issue, Two macros is not that bad. It is the solution required when using the DnD5e by Roll20 sheet, since so many of the sheet's abilities and attributes are named differently depending on whether the character is a PC or NPC. I have two master macros, and I generally know which one to use by context.
Ohh, yeah I see what you mean. That could work, will have to try it out to see if it's any good.