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

Strange API/Chat Menu Button/Roll Template interaction

1570296112
Kraynic
Pro
Sheet Author
I'm not sure which section of the forums this should be in, but I am going to throw it in API since I ran into it messing with API commands. First of all, I ran into this issue while setting up the ammo script.  On the Palladium Fantasy 1E sheet that I wrote, there is a repeating section for ranged attacks.  Included on the sheet for player or DM use is a "Notes" text field (@{attack_reference}) that uses the description part of the roll template.  I recently added a box to track ammunition in the repeating row and decided to install and add Ammo to my short API script list. The macro that is rolled when the attack is rolled looks like this: <button class='rangeddice' type='roll' title='Strike (Attack) Roll with Damage' name='roll_rangedattack' value="&{template:custom} {{color=blue}} {{title=**@{character_name}**}} {{subtitle=attacks with @{weapon_attack}}} {{Attack= [[d20cs>@{hth_ranged_critical}+@{weapon_strike}+@{temp_strike}]]}} {{Damage= [[@{weapon_damage}+@{temp_damage}]]}} {{desc=@{attack_reference}}}">S</button> Since this is a repeating section, I do create the macro for Ammo as a character ability and tell people not to change the position of the weapon with ammunition without letting me know so that I can alter the Ammo macro to be pointing to the right position in the order.  Since shots are done one at a time, I don't have to have a query for how many arrows are used.  On a test character, the Ammo macro (named "-Arrow") looks like this: !wammo @{selected|character_id} repeating_rangedattacks_$0_ammunition -1 arrow I thought I would make a chat menu button out of this ability by putting it in the Notes (@{attack_reference}) text field on the sheet: [Subtract Arrow](~-Arrow) Now comes the interesting part.  The Ammo macro call requires the token to be selected which is fine, but the chat menu is broken when hitting the button on the character sheet. However, if I call the same attack roll from the sheet using a listing from the Universal Chat Menu script, the button not only appears like I expected, but works. My question is:  What kind of voodoo is this?  Anyone have any idea why it works one way, but not the other?
1570296917

Edited 1570297505
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
This is because you're trying to take advantage of a shortcut in your button that works only in specific situations. I've never been able to fully discover the exact situations that allow that short form button to work. The full button syntax is: [Display text](~Char Name|ability_name) Which you can use the following to make it character agnostic: [Display text](~@{character_name}|ability_name) Universal chat menus probably constructs the button using either the long form ability command button syntax or by directly creating the <a> element for the button. Hope that helps. EDIT: I'm also reasonably certain that the shortcut method is an emergent behavior of the ability command syntax, not the intended behavior. So, use at your own risk most likely. And, realized you weren't talking about a button created by Universal chat menus. So, ignore that part of my post, but the rest of it holds true. Although, do you have a custom CSS extension to change the appearance of command buttons?
1570299599
Kraynic
Pro
Sheet Author
The css change to the button appearance is part of the roll template (part of the sheet). Putting the character name in the Notes entry did the trick for it to be recognized when just rolling from the sheet.  I still find it odd that it would work when the same roll is being called from the chat menu command, while not working when hitting the button on the sheet.
1570315919
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, like I said, that shortcut is tempermental. Keith swears by it, but it only works about 50% of the time for me.
1570316794
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I've never tried saving an Ability with a name that begins with a "-". Perhaps it parses oddly? I find that I do have to reference the sheet when calling an ability resident on another sheet. Cf. ex. 3 here .
1570329944
Kraynic
Pro
Sheet Author
keithcurtis said: I've never tried saving an Ability with a name that begins with a "-". Perhaps it parses oddly? I thought about that, and in the game I ran Thursday night, I set it up without the minus sign.  The reference is to an ability on the sheet.  Only 2 characters in that game were using it, and both needed to be worded different since one was arrows and the other was bolts, so I just put the macros on their sheets.  So, in theory it shouldn't need the name, but I do have to put the name in to get it to work when rolling from the sheet roll button for some reason.  I didn't even think of that until Scott C. mentioned it. Just really odd for it to work without the name in the ability call if I am using a chat menu button to call the roll versus using the button on the sheet.  I guess I'll go back to the idea there is some sort of black magic involved, and I will just put the names in and continue on that way...