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

Nesting Macro Won't Play Sounds from API script

Hi! I'm fairly new to doing API/Macro stuff, and I just put in the Roll20 Audio Master. Now, what I've done is use a custom table for critical hits for my players to have a little flavor. I made a table for each type of damage and then I made a macro for those with inline rolls and a sound effect that plays with that macro from Audio Master (fiery sounds for fire crit, arrow shot noise for piercing etc.) What I want to do is take those macros and make one Critical Hit nested query macro for my players to have one condensed button to push and make the magic happen. What's going on is that when I do that, the SFX show up as choices in the dropdown for some reason, and when I select any of the choices in the nest, it doesn't play a sound. An individual macro looks like this: #Crit-Acid You attack with caustic acid: [[ 1t[Acid-Crit] ]] !roll20AM --play|Acid Blast Spell - Pitch Michael The nested macro looks like this: #Critical-Hit! ?{Which macro?|Cold,#Crit-Cold |Acid,#Crit-Acid |Bludgeoning,#Crit-Bludgeoning |Fire,#Crit-Fire |Force,#Crit-Force |Lightning,#Crit-Lightning |Necrotic,#Crit-Necrotic |Piercing,#Crit-Piercing |Poison,#Crit-Poison |Psychic,#Crit-Psychic |Radiant,#Crit-Radiant |Slashing,#Crit-Slashing |Thunder,#Crit-Thunder } I looked up what the problem may be and it seems the characer | may be the problem, but when I replace that with the HTML code equivalent as I see it in the wiki's suggestion, the sound doesn't play... Any tips? I'm not great with coding but I learn pretty quickly, if anyone would kindly help.
1483455150

Edited 1483460014
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi Proto, Thanks for using the script. I've figured out what's going wrong through some testing in my game and logging the chat messages in the script. The problem is that the script takes everything after the | as the track/list name. When you nest a global macro in a query like that, you have to put a space after the macro call as you are doing. This however results in the script receiving "!roll20AM --play|Acid Blast Spell - Pitch Michael " instead of "!roll20AM --play|Acid Blast Spell - Pitch Michael". This means it looks for a track named with a hanging space at the end. I'll get a patch out tonight after work that will trim hanging spaces off of the track/list arguments along with hopefully a fix for that intermittent crash you reported on the script thread. Not related to the problems with the script, but when using advanced macros that utilize html escapes I would recommend making them as character abilities instead of global macros as the global macros will eat the html entities anytime they are reopened and then resaved. Happy Rolling, Scott EDIT: Had some time earlier than expected. The script now trims hanging spaces with v1.04.
Oh you're a lifesaver. Thank you so much!
1483466960
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Np, You'll have to manually copy/paste the code from github to take advantage of v1.04 since they just did a merge day last night, could be a week or three before the next one.
Okie doke, I copy/pasted from that source and I'm still having the same problem even after updating by copy/pasting from your repository and adding spaces at the end of each sound in the individual macros :c I'll give ya a screenshot of what's happening: It treats the sounds as choices, and when I choose something "normal" (e.g., "Cold"), it rolls from the table I created for this properly, but it does not play the sound associated with each damage type. I'm really sorry to be a bother, maybe I'm not doing something correctly? Each macro works separately when clicked on its own, but when nested in a dropdown it just refuses to cooperate >:|
1483468793

Edited 1483468921
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
ah, that's what an advanced roll query looks like when something has eaten the html replacements (like opening and resaving a global macro). I'd switch them all over to being character abilities to avoid this problem in the future. My favorite way to do this is to make a generic character, name it abilities or some such, give everyone edit and control ability. Once all the macros are in it, I then archive it. The macros are still callable via %{abilities|MacroName}, but your players won't be able to access it and mess up the finicky html replacements. Also, looking at what is showing up there, it looks like you have a few options that you want to play multiple sound effects at once. Instead of doing multiple command lines, you can combine them into one command line and/or action group. Here's an example using your piercing option: !roll20AM --play|Arrow Sound by ExoMemphiz|Shortbow Arrow Hits Wooden Shield - Jean-Baptiste This will play both tracks simultaneously. If you wanted them to be played with a slight delay in there, you could do: !roll20AM --play|Arrow Sound by ExoMemphiz --play,delay:0.2|Shortbow Arrow Hits Wooden Shield - Jean-Baptiste This will play the Arrow sound and then play the Arrow hits Wooden Shield 2/10 of a second later. Hope that helps, Scott EDIT: Also, since I'm pretty sure you want your players to be able to use these make sure all these tracks are tagged as player accessible or disable the script's access restrictions via the chat menu accessible from !roll20AM --config.
1483469225

Edited 1483471062
Okay! Thank you so much, I will try that right now. EDIT: HOLY CRAP FINALLY IT WORKED THANK YOU
1483477974

Edited 1483477995
It would be nice if Roll20AM supported alternate syntax for | and , (e.g. # and /)
1483479712

Edited 1483479769
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Glad it's working Proto. I'll look into adding alternate syntax for separators, it's certainly something that would be useful.
1483489198

Edited 1483491152
I'll share how my stuff works so others can use it too: Before you start, you will need the Roll20 Audio Master (the latest version). First, I made rollable tables with a list of variable critical hit effects (you can add more weight to some and less to "better" outcomes) for each type of damage: bludgeoning, slashing, piercing, fire, cold, acid, poison, necrotic, psychic, radiant, lightning, thunder, and force. These tables are found all over the Internet with a simple search and can be tweaked as the DM sees fit. This is my Radiant damage table: Next, I created a character named API to use as my guinea pig. In its abilities, I made macros for each of the damage types with inline rolls, flavor text, special effects, and a sound effect (special effects tips can be found  here ). The macros look like this: You attack with holy radiance: [[ 1t[Radiant-Crit] ]] !roll20AM --play|Restorative Spell - Pablo Betancourt /fx nova-holy @{target|Source|token_id} @{target|Target|token_id} The character | (vertical bar) does not translate in these for nested/query macros, so I have the HTML equivalent to that character. Rolling this macro chooses a random effect off of the table I made for Radiant damage. A roll would look like this: And it would play the sound I specified from the Roll20 Audio Master command.  Now, to make this easier on my players, I made a nested/query macro to handle these, and with the help of Roll20AM's creator I tweaked it until I had a dropdown menu that used API's abilities and ran the correct macro commands. This is what the code looks like: ?{Damage Type?|Cold,%{API|Crit-Cold}|Acid,%{API|Crit-Acid}|Bludgeoning,%{API|Crit-Bludgeoning}|Fire,%{API|Crit-Fire}|Force,%{API|Crit-Force}|Lightning,%{API|Crit-Lightning}|Necrotic,%{API|Crit-Necrotic}|Piercing,%{API|Crit-Piercing}|Psychic,%{API|Crit-Psychic}|Poison,%{API|Crit-Poison}|Radiant,%{API|Crit-Radiant}|Slashing,%{API|Crit-Slashing}|Thunder,%{API|Crit-Thunder}} Now my players can have some really cool flavor text and sound to go with any critical hits they make against an enemy! I hope this code and this thread can help anyone else wanting to do something similar with sound and macros :)