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 .
×

Having Trouble Integrating TokenMod into a Dropdown Menu

1621371434

Edited 1621371498
Hello everyone, I'm trying to make a dropdown menu for my druid so that he can shapeshift and have his token, health, and AC change automatically on his token display.  I've done a couple of other simple things using TokenMod (I gave my players with lanterns a button to turn their lantern on and off and one to let my players cast the Light spell from DnD 5e on other tokens), but now when I try this I run into several problems. The first problem I ran into was that the modified NPC sheets that my druid is using aren't found when doing @{'NPC Name'|character_id}.  In my original two macros, I used this format to target a specific character with --ids.  I was able to extract the IDs of the NPCs using @{target|character_id} and since character IDs appear to be persistent across play sessions, I hardcoded those IDs into the macro.  Furthermore, I discovered that I can't use '|' in the TokenMod syntax when it's inside a dropdown list, so I'm using '#' instead per a forum post I read. The error I'm getting now is: " TypeError: Cannot read property 'substring' of undefined " Which looks to be a somewhat generic error when working with the API. Here is my code in full: ?{Choose Shape| Human, !token-mod {{ --ids '-M_s0zEsYFVv5ha87pZH' '-M_sAO_yaDUoU4M_ZOuU' --off night_vision --set represents#@{Marcelyn#character_id} currentside#1 }} | Bear, !token-mod {{ --ids @{Marcelyn#character_id} '-M_sAO_yaDUoU4M_ZOuU' --off night_vision --set represents#'-M_s0zEsYFVv5ha87pZH' currentside#2 }} | Tiger, !token-mod {{ --ids '-M_s0zEsYFVv5ha87pZH' @{Marcelyn#character_id} --on night_vision --set represents#'-M_sAO_yaDUoU4M_ZOuU' currentside#3 night_distance#60 }} } Any help would be appreciated, thank you!
1621372769
The Aaron
Roll20 Production Team
API Scripter
@{name#character_id} simply won't work.&nbsp; Roll20's parser doesn't understand that syntax.&nbsp;&nbsp; You'll probably have more luck building a chat menu than using a roll query.&nbsp; Check here:&nbsp;<a href="https://app.roll20.net/forum/post/5899495/roll20-tips-and-tricks-innovative-solutions-to-common-problems/?pageforid=5927072#post-5927072" rel="nofollow">https://app.roll20.net/forum/post/5899495/roll20-tips-and-tricks-innovative-solutions-to-common-problems/?pageforid=5927072#post-5927072</a>
Thank you very much for the suggestion!&nbsp; I just have one more question.&nbsp; Is it possible to get the character_id by using a token's name?&nbsp; For example, something like: @{&lt;Name_Under_Token&gt;|token_character_id}
1621393854
The Aaron
Roll20 Production Team
API Scripter
You can get the character id for the character a selected (or targeted) token represents with: @{selected|character_id}
@{selected|character_id} I think is what you are looking for Shawn S. said: Thank you very much for the suggestion!&nbsp; I just have one more question.&nbsp; Is it possible to get the character_id by using a token's name?&nbsp; For example, something like: @{&lt;Name_Under_Token&gt;|token_character_id}