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

Token Action Chat List for Attack Options

1726302574

Edited 1726302889
Earlier this evening I was prepping the Token/Sheet for a brand new player.  Normally, I use Token Action and I did so for this one.  I noticed something that I is different (I must have missed it before).  TA now creates a chat menu for spells.  This is great and it inspired me to try my hand at creating one for Melee weapons.  After examing the code and taking careful notes of it and the Abilities (I am using the D&D 5e Roll20 sheet), the return was an utter failure. Here is the code that TA created for this 5th Level Cleric Spell list in Chat: /w @{character_name} &{template:atk} {{desc=**Cantrips:** [Guidance](~repeating_spell-cantrip_-NJakXCCSu4rAlXryfjd_spell) | [Light](~repeating_spell-cantrip_-NJak5bPezSt3hD3QDQi_spell) | [Mending](~repeating_spell-cantrip_-NohyC3IvKsVxP66LYq5_spell) | [Sacred Flame](~repeating_spell-cantrip_-NJakUnf0G84pTJngI3V_spell) **1st:** [Bless](~repeating_spell-1_-NJakk-1EXLJrsspbQps_spell) | [Cure Wounds](~repeating_spell-1_-NJaknvmqRh4n1clvrru_spell) | [Guiding Bolt](~repeating_spell-1_-NJalRks2IZe8FqvkOij_spell) | [Healing Word](~repeating_spell-1_-NJaluizjNui9MvpOSRj_spell) | [Shield of Faith](~repeating_spell-1_-NJalktz1oh6fqhd24eU_spell) **2nd:** [Hold Person](~repeating_spell-2_-NX6sgUqWxeRhhCpURzo_spell) | [Prayer of Healing](~repeating_spell-2_-NlKu7jaM8jg2l-AWyHA_spell) | [Silence](~repeating_spell-2_-NX6slN9TILYkSoGSFcW_spell) | [Spiritual Weapon](~repeating_spell-2_-NtDm3Q1yZMdJevtXwKS_spell) **3rd:** [Dispel Magic](~repeating_spell-3_-NtDltTAY9p8x88nOnMZ_spell) | [Remove Curse](~repeating_spell-3_-NtDmyQlCY0Q8fhBJ0dS_spell) | [Revivify](~repeating_spell-3_-NtDi7MYfDelhrE23mjn_spell) }} Here is my first attempt (only doing one category and making sure to include the final brackets). /w @{character_name} &{template:atk} {{desc=**Melee** [Dagger](%{-McAGGfrbaMJ7rqgtyse|repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack}) | [Crossbow](%{-McAGGfrbaMJ7rqgtyse|repeating_attack_-NJau8e1Gc68MCiOzfmQ_attack}) | [Quarterstaff](%{-McAGGfrbaMJ7rqgtyse|repeating_attack_-NJanooaK-yWBhiCHMRN_attack}) }} Here is my second attempt - after noting that the beginning was shortened to ~before the "repeating" and the absence of internal brackets inside. /w @{character_name} &{template:atk} {{desc=**Melee** [Dagger](~repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack) | [Crossbow](~repeating_attack_-NJau8e1Gc68MCiOzfmQ_attack) | [Quarterstaff]( ~repeating_attack_-NJanooaK-yWBhiCHMRN_attack) }} I tried other changes (one at a time) to no avail.  Each time i received this return: TypeError: Cannot read properties of undefined (reading 'substring') I am really not sure where my mistake is.  Any ideas or fixes?
Other Troubleshooting: Double-checked line-breaks in both the original as well as my own.  Ran the code in a new game with no API's installed followed by with Token Action Installed.
1726304719

Edited 1726307375
You appear to be missing the character reference - add that and it should work.  I'm hungry and can't be bothered to troubleshoot.  Don't mind me. It should work, assuming those strings correspond to correct attack indexes. /w @{character_name} &{template:atk} {{desc=**Melee** [Dagger](~@{character_name}|repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack) | [Crossbow](~ @{character_name}| repeating_attack_-NJau8e1Gc68MCiOzfmQ_attack) | [Quarterstaff](~ @{character_name}| repeating_attack_-NJanooaK-yWBhiCHMRN_attack) }} EDIT: Alternatively, just use this, I wrote it for myself a while back and it lists the attacks on your sheet (up to 15 of them, but can be easily expanded) with buttons to roll those attacks. /w @{character_name} &{template:default} {{@{repeating_attack_$0_atkname}=[Roll](`@{@{character_name}|repeating_attack_$0_rollbase})}} {{@{repeating_attack_$1_atkname}=[Roll](`@{@{character_name}|repeating_attack_$1_rollbase})}} {{@{repeating_attack_$2_atkname}=[Roll](`@{@{character_name}|repeating_attack_$2_rollbase})}}{{@{repeating_attack_$3_atkname}=[Roll](`@{@{character_name}|repeating_attack_$3_rollbase})}}{{@{repeating_attack_$4_atkname}=[Roll](`@{@{character_name}|repeating_attack_$4_rollbase})}}{{@{repeating_attack_$5_atkname}=[Roll](`@{@{character_name}|repeating_attack_$5_rollbase})}}{{@{repeating_attack_$6_atkname}=[Roll](`@{@{character_name}|repeating_attack_$6_rollbase})}}{{@{repeating_attack_$7_atkname}=[Roll](`@{@{character_name}|repeating_attack_$7_rollbase})}}{{@{repeating_attack_$8_atkname}=[Roll](`@{@{character_name}|repeating_attack_$8_rollbase})}}{{@{repeating_attack_$9_atkname}=[Roll](`@{@{character_name}|repeating_attack_$9_rollbase})}} {{@{repeating_attack_$10_atkname}=[Roll](`@{@{character_name}|repeating_attack_$9_rollbase})}} {{@{repeating_attack_$10_atkname}=[Roll](`@{@{character_name}|repeating_attack_$9_rollbase})}} {{@{repeating_attack_$11_atkname}=[Roll](`@{@{character_name}|repeating_attack_$11_rollbase})}} {{@{repeating_attack_$12_atkname}=[Roll](`@{@{character_name}|repeating_attack_$12_rollbase})}} {{@{repeating_attack_$13_atkname}=[Roll](`@{@{character_name}|repeating_attack_$13_rollbase})}} {{@{repeating_attack_$14_atkname}=[Roll](`@{@{character_name}|repeating_attack_$14_rollbase})}}{{=}} &{noerror}
The problem is that the attack index/reference listed isn’t present on the character sheet   I think Tuo is correct and you have incorrect attack indexes.  Are these created as Token Actions on the character sheet of the character they are being used for? Do you have more than one character with the same name? Another possibility is that Roll20 is looking in the wrong place - those attack indexes are on a different sheet.  If you’re just looking for chat menus to list out all attacks for your players, you could install the Statblock MacroMule  which creates chat menus for all PCs and NPCs for attacks, spells, rolls, and stats. 
1726380625

Edited 1726381293
@Tuo I tried both and neither worked.  I may not be understanding the second code.  I get the same result.  Is there something I need to edit in that code block? @Jarren Thanks.  As for the attack Indexes, I double-checked just to make sure.  There are Token Actions in the attributes and Abilities (Abilities) (e.g. Dagger) I opened up that ability and copied the attack index from there. Here is the exact code for the Ability called "Dagger" %{-McAGGfrbaMJ7rqgtyse|repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack} That ability outputs correctly.  The character's name is Misha.  I can type directly into the chat any of the following and get a correct output. %{Misha|Dagger} %{Misha|repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack}%{-McAGGfrbaMJ7rqgtyse|repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack} %{-McAGGfrbaMJ7rqgtyse|Dagger} %{-McAGGfrbaMJ7rqgtyse|repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack} The Token Actions for all of the melee attacks are present and created by the API Token Action. I have also double-checked that the Token was correctly linked to correct sheet (it was) and that there was only one character with that name.  I double-checked all the Abilities/Token Actions in the same manner as Dagger. I may look into running a Macro Mule if I must, but it seems like a shame not to be able to keep everything contained within the sheet.  The Spells Ability/Token Action works perfectly.
1726384198

Edited 1726384277
Jako Dar said: @Tuo I tried both and neither worked.  I may not be understanding the second code.  I get the same result.  Is there something I need to edit in that code block? No, it should work as is, copied into an ability. It should output something like this (with the attacks from the character sheet it was added to): It loads the attacks directly from the character sheet, so it should not interact with the token action maker in any way. As for the indexes, you can just count down the list of your attacks to get the correct index for an attack, starting from 0. So, if the attack is third down on the list, you use repeating_attack_2_ to refer to it.
Jako Dar said: I tried other changes (one at a time) to no avail.  Each time i received this return: TypeError: Cannot read properties of undefined (reading 'substring') I am really not sure where my mistake is.  Any ideas or fixes? I'm getting that error when I simply cut and paste the command into the chat window instead of as an Ability on a character sheet. That error message basically means that Roll20 doesn't know which character sheet to look on.  From the repeating attack indexes you posted above, this should work as an Ability on Misha: /w @{character_name} &{template:atk} {{desc=**Melee** [Dagger](~repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack) | [Crossbow](~repeating_attack_-NJau8e1Gc68MCiOzfmQ_attack) | [Quarterstaff](~repeating_attack_-NJanooaK-yWBhiCHMRN_attack) }} Alternatively, if you select a token representing 'Misha' then this should work: /w @{selected|character_name} &{template:atk} {{desc=**Melee** [Dagger](~selected|repeating_attack_-NJb-q7wQ1YxhvORNJIx_attack) | [Crossbow](~selected|repeating_attack_-NJau8e1Gc68MCiOzfmQ_attack) | [Quarterstaff](~selected|repeating_attack_-NJanooaK-yWBhiCHMRN_attack) }} Lastly, this should work for any selected token (this is basically the same thing that the Statblock Macromule does): /w @{selected|character_name} &{template:atk} {{desc=**Melee** [@{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) }}
Thank you both for your help!!   It is working and my player loves it!! It is rediculous to learn that THE error was that i was dumping it into chat and hitting enter instead of puting it into an ability and making it a token action.  I really have no idea why that threw an error (the token was still selected when I hit enter),  I may to go back and retest some of my other "failed" macros (as well as testing my own assumptions).
Jako Dar said: Thank you both for your help!!   It is working and my player loves it!! It is rediculous to learn that THE error was that i was dumping it into chat and hitting enter instead of puting it into an ability and making it a token action.  I really have no idea why that threw an error (the token was still selected when I hit enter),  I may to go back and retest some of my other "failed" macros (as well as testing my own assumptions). Ah, that would be because an attribute call without a reference works in a character sheet, because it auto-fills the host character as reference, but sent from chat, it's missing the character. I made mine with the assumption of saving it on to the character sheet using it, but  If you want it to work from any location on selected character, you could place a "selected" reference to all of the attribute calls without a reference.