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

Using ChatSetAttr in Buttons on Macro

1775273596

Edited 1775273953
I have a chat macro that opens  up information on a selected character's carried money. I'd like to be able to add or subtract values from the different coin categories, in this case, for the AD&D 1e character sheet. I'll be using !ChatSetAttr. I'm happy with the format I have, except the buttons that are showing are presently for rotating characters and comes from a token modifier button (for "rotate") Here is the Token Chat: I'm happy with the layout of the chat which shows carried coins for the character token selected. I lists the types of coins, shows the actual number the character has and, in parenthesis, the equivalent Gold Piece value. I want the DM or the player to click on the button to add or subtract from a category of coin (CP, SP, EP, GP, or PP). Presently, the buttons were just copied from the token rotate button and use TokenMod. Here is the code for the top line for copper pieces: CP: ``@{selected|cp}`` ([[@{selected|cp}/20]]) [Copper](!token-mod  --set rotation|?{Enter Angle or leave blank for 0°|0}) Of course, I have another chat for rotating character tokens, but I wanted this as a basis on which to develop the addition or subtraction of CP in this case. The actual chat that I paste into the chat entry is: !modattr --sel --cp|?{Make sure only one character is selected! Copper: Add or subtract (negative)|0} I paste that into the chat box: And the process unwinds as I expect it to do: So after clicking submit on the 15 CP I am adding The 15 combines with the existing 7 and ChatSetAttr (manifested as !modattr) makes the change to the 1e AD&D sheet copper piece field, CP to 22. Running the Coins2 macro again and the updated 22 CP are displayed: OK, that's wonderful and what I must do now is to incorporate this macro command !modattr --sel --cp|?{Make sure only one character is selected! Copper: Add or subtract (negative)|0} into the button for the Copper pieces. First, "?" is replaced with "?" Next is where I run into problems. Let's just look at the line on the whole macro for copper pieces. Here it is with the "rotate" code that I put in there to save the space for !modattr: CP: ``@{selected|cp}`` ([[@{selected|cp}/20]]) [Copper](!token-mod  --set rotation|?{Enter Angle or leave blank for 0°|0}) I thought it would be a simple matter of using the modattr code above and replace "?" with "?" CP: ``@{selected|cp}`` ([[@{selected|cp}/20]]) [Copper](!modattr --sel --cp|?{Make sure only one character is selected! Copper: Add or subtract (negative)|0}) Unfortunately, this reveals issues with the CP line. In the screenshot below, the above code is highlighted. In the chat, circled in red, we can see how the button gets mangled: If anyone was able to follow that and can help me with what I'm missing, I'd appreciate it, thanks. -- Tim
1775275989

Edited 1775276125
Gauss
Forum Champion
You used ")" in the Copper line. That ended the button.  Button structure:  [buttonname](buttoncommand) You have a ")" (without quotes) in the middle of the buttoncommand.  Example:  [buttonname](buttoncom)mand) Roll20 sees:  [buttonname](buttoncom) You might try using an html entity in place of the ). 
1775300658

Edited 1775301137
Gauss said: You used ")" in the Copper line. That ended the button.  Button structure:  [buttonname](buttoncommand) You have a ")" (without quotes) in the middle of the buttoncommand.  Example:  [buttonname](buttoncom)mand) Roll20 sees:  [buttonname](buttoncom) You might try using an html entity in place of the ).  Thanks Gauss, will look at both this and... Bingo! I should have realized it was the parenthsis. Instead I was copying and altering macro statements I found on line that were meant to be directly entered into the chat dialogue box. Wonderful stuff, delighted to see this worked. -- Tim