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

Macro for listing attacks

1572139472

Edited 1572139488
Is there any possibility to read the attacks of a character sheet while using macros? The goal is a macro for attacking with any token.
1572141966
Mike deBoston
Compendium Curator
The answer is usually yes but it depends entirely on which character sheet you are using. Which one are you using?
1572172109
Ziechael
Forum Champion
Sheet Author
API Scripter
When you start to look into it further I'd recommend heading down the chat menu route. Best of luck!
I'm using the D&D 5e character sheet
1572907062

Edited 1572907152
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
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.
1573022392
Mike deBoston
Compendium Curator
I had never seen or read about the &{noerror} option before. That's a neat trick.
keithcurtis said: 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) That's pretty amazing! Thanks. Anyway it doesn't solve my problem of having one general macro, because of the variable number of attacks of the character. It would be perfect with any function that allows to read that number and a kind of loop for generating the macro, but I imagine there isn't this possibility. Would I be able to do that with the API?
1573063356
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That's about the best you can do with macros, which do not have conditional logic (i.e. don't know when to stop the repeat). The Shaped Sheet has some great reporting macros with this logic built in. No further action or coding required. For OGL and other sheets without such functionality, there are some great API scripts that do this. MenuMaker and Universal Chat Menus can handle this and there are some fully-realized sample macros all coded out and ready to go. Here is an example which is overkill for your use, but will show what is possible. Also, for a slightly different take, there is TokenActions , a script that makes token action buttons of all attacks (PCs) and Actions (NPCs) and more.