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 Commands in Dropdown Menu

1691656043
Essen
Pro
Marketplace Creator
Hi there. I want to make a single Macro Bar button to handle a handful of Token Mod and ChatSetAttr commands, but the commands using the | character is messing up the dropdown. Anyone know how to make it work?
1691670148

Edited 1691682200
From the  ChatSetAttr README : If you want to use the '|' or '#' characters inside an attribute value, you may escape them with a backslash: use '|' or '#' instead. For TokenMod, you can replace the '|' with a '#'. If you post your code then someone can help make sure it’s parsed correctly. 
1691690486

Edited 1691691161
Essen
Pro
Marketplace Creator
I think I worked it out.  I kept seeing examples with [[ ]] around the macro, but removing them gets it all to work. Here's the macro, just as an FYI: ?{Scourge |  PC 0,!setattr --sel --scourge# |  PC +2,!modattr --sel --scourge#2 |  PC +4,!modattr --sel --scourge#4 |  PC Trigger,!modattr --sel --hp#-scourge !modattr --sel --scourge#-1 |  NPC 0,!token-mod --set bar3_value# | NPC +2,!token-mod --set bar3_value#+2 | NPC +4,!token-mod --set bar3_value#+4 | NPC Trigger,!token-mod --set bar1_value#-@{selected|bar3}  !token-mod --set bar3_value#-1 }
1691845739
Andreas J.
Forum Champion
Sheet Author
Translator
If you have hard time getting a dropdown to work, you could write a Chat Menu that when activated shows in Chat a list of buttons to the commands you want. Example with API/Mod command: <a href="https://wiki.roll20.net/Chat_Menus#Bit_of_Everything" rel="nofollow">https://wiki.roll20.net/Chat_Menus#Bit_of_Everything</a> &nbsp; While using a Chat Menus results in one extra click, it's often easier to create instead of some dropdowns that will need lots of special characters to work. Menus are smart to whisper to self or GM to avoid cluttering player's chat. Or you could group all tokenmod commands in one macro dropdown menu like this , and then have the setAttr in a separate dropdown.