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

Need some help with an Attack Macro

So my goal would be to create a generic macro on the macro bar that will initiate the attack from the character sheet of a selected token. I'm using the Pathfinder Official character sheet and would like the macro to initiate the attack listed on the NPC version of this sheet. I saw a thread from two years ago actually calling the entire offense section of the NPC sheet which looked to allow you to choose which attack on the sheet to use as shown in the picture below. This would actually be pretty ideal. Here is the link to that post:&nbsp; <a href="https://app.roll20.net/forum/permalink/4776914/" rel="nofollow">https://app.roll20.net/forum/permalink/4776914/</a> Any help would be greatly appreciated.
So I've been able to get this far. /w gm &amp;{template:default} {{name=Attack}} {{Attacks= [Melee1](!&amp;#13;#Melee1)[Melee2](!&amp;#13;#Melee2) [Ranged1](!&amp;#13;#Ranged1) [CMB](!&amp;#13;#CMB)}} Which produces the links to the macros as I wanted. But I have not been able to figure out how to link the names of the attack names instead of using the static "Melee1" etc. This forum post shows a macro that does so: <a href="https://app.roll20.net/forum/post/5739281/repeating-attack-help" rel="nofollow">https://app.roll20.net/forum/post/5739281/repeating-attack-help</a> !power {{ --emote|** @{selected|token_name} Uses a Weapon**&nbsp; --tokenid|@{selected|token_id}&nbsp; --titlebackground|none&nbsp; --titlefontshadow|none --whisper|@{selected|character_name} --corners|10 --format|atwill --name|^^Weapons --leftsub|@{selected|character_name} --rightsub|Level @{selected|level} @{selected|class}^^ ^^ --Weapons:| ^^[@{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) [@{selected|repeating_attack_$4_atkname}](~selected|repeating_attack_$4_attack) }} So I know I need to use something like:&nbsp; repeating_attack_$0_atkname, but I don't know the field name that's used in the Pathfinder Official PC or NPC sheets for the name of an attack. Could anyone point me in the right direction for the name of this field and perhaps how to get closer to the results in the two screenshots I've linked?
1555614250
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Not experienced with the sheets in question, but you can frequently find the field names by clicking on that section of the sheet and choosing "Inspect". Look for a pattern similar to the repeating field one you called out above.
Awesome! Thank you very much. That tip helped tremendously to find the field names I was looking for. Now I have this code: /w gm &amp;{template:default} {{name=Attack}} {{Attacks= [@{selected|repeating_npcatk-melee_$0_atkname}](~selected|repeating_npcatk-melee_$0_attack) [@{selected|repeating_npcatk-melee_$1_atkname}](~selected|repeating_npcatk-melee_$1_attack) [@{selected|repeating_npcatk-ranged_$0_atkname}](~selected|repeating_npcatk-ranged_$0_attack) [CMB](!&amp;#13;#CMB)}} Producing this result. The attacks appear with the proper names dynamically for whatever token I have selected and the buttons in the chat call the attack button from the character sheet. So now I'm to the point where I'm just being nit-picky, but for characters that have fewer attacks than the macro looks for it returns the somewhat awkward selected|repeating_npcatk-melee_$1_atkname , as shown below. I can live with this, but if keithcurtis or anyone else has any idea how to return a null result so that a button does not appear in the chat if the character does not have that many attacks, that would be awesome. Ideally I'd love to be able to select the token on the battlefield, click the token action button, and the chat shows a dynamic list as it does below with the names of all the attacks the character has without getting buttons that don't work because the selected character doesn't have enough attacks. My first thought would be to use a "IF/ELSE" statement to filter out results, but I was pretty sure I saw somewhere that this is beyond the capabilities of Roll20's macro system.
1555655909
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You are right. Macros lack conditionals; they are basically fancy dice rolling expressions that print to chat. And yeah, I don't know how to solve the problem of determining the number of repeating macros, either. I use the Shaped sheet for 5e that has a lot of this stuff baked in.
1555657324

Edited 1555657508
Actually i think I figured out a workaround. For the example above I just added an extra attack entry for that specific character, but only entered a single space for the name and didn't fill in any more of the fields in the attack entry. Now it comes up a small purple box, but it doesn't have any additional error messages. I think this will work for now. Thanks again for your help. Update: Also I found a list of all the field names under the Advance Use section of the Pathfinder Official character sheet roll20 wiki page. Hopefully this will help anyone else having similar problems. <a href="https://wiki.roll20.net/Pathfinder_Official#Advance_Use" rel="nofollow">https://wiki.roll20.net/Pathfinder_Official#Advance_Use</a>