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

Modify my Attack Token Action to include a Sound Effect

January 20 (3 weeks ago)
Paul
Pro

Please help. I tried finding this info here and I tried figuring it out, but I'm at a loss. I am not well versed in this coding business, please be gentle.

So Alien RPG, I have a monster token with a token action to ATTACK that will randomize its attack from the character sheet; I want to add code to that action that will include a sound effect with the roll.


I've managed to successfully create a macro that plays that sound; I've created a token action that plays the sound; I've created a token action that plays the macro that plays the sound - but I can't figure out how to modify my ATTACK token action to play the sound.

Token Action for ATTACK:  "@{randomizeattack-attr}"  this works, rolls random attack

Macro for SOUND: "!roll20AM --audio,play|face03finalemb"   this works, triggers sound titled "face03finalemb"

Token Action for SOUND: "#face03finalemb" or "!roll20AM --audio,play|face03finalemb"  both of these work, triggers sound from macro or direct from API.

Token Action for ATTACK with SOUND, one command per line or two commands per line, commands in either order:

"@{randomizeattack-attr} #face03finalemb"

"@{randomizeattack-attr} !roll20AM --audio,play|face03finalemb"

these do not work as intended, the attack roll happens, but no sound; if I change the command order to sound first then attack, the result is the same, IE attack roll but no sound.


If the solution isn't fixing my code in this macro, I think I'm going to create a token action to bring up a Chat Menu and I'll select the sound from a "soundboard" menu. I don't know. Any feedback will be appreciated. I've read through what I could find on this and got burnt out. GLHF. Thanks. Peace.

January 20 (3 weeks ago)

You need the ! command to be on a new line, that should resolve your issue.

January 20 (3 weeks ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Posting the actual code of the token actions might help if you need more assistance.

January 22 (3 weeks ago)

Edited January 24 (3 weeks ago)
Paul
Pro

Thanks for the replies. I managed to get this to work after taking the whole code suggested by Keith. First, I used the token action, then in the chat box I hit the up arrow to grab the whole code. I added the !roll20am code on a separate line at the end and it works. I modified it to work on any {selected} token so I can copy it into other monsters and I added a query to the !roll20am so I can pick which sound plays. The sound won't always correspond with the attack but I'm ok with that. Woo.

@{Selected|roll_command} &{template:alien} {{character-name=@{Selected|character_name} }} {{roll-name=@{Selected|xenoattack3_name} }} {{roll-type=3}} {{current-comment=@{Selected|xenoattack3_desc} }} {{current-damage=@{Selected|xenoattack3_dmg} }} {{roll-dice-cmd=@{Selected|xenoattack3_dice} }} {{roll-dice=[[@{Selected|xenoattack3_dice}]] }} {{current-dice=@{Selected|xenoattack3_base} }} {{base-dice=[[@{Selected|xenoattack3_base}]] }} {{base-roll-one=[[1d6]] }} {{base-roll-two=[[1d6]] }} {{base-roll-three=[[1d6]] }} {{base-roll-four=[[1d6]] }} {{base-roll-five=[[1d6]] }}  {{base-roll-six=[[1d6]] }} {{base-roll-seven=[[1d6]] }} {{base-roll-eight=[[1d6]] }} {{base-roll-nine=[[1d6]] }} {{base-roll-ten=[[1d6]] }} {{base-roll-eleven=[[1d6]] }} {{base-roll-twelve=[[1d6]] }} {{base-roll-thirteen=[[1d6]] }} {{base-roll-fourteen=[[1d6]] }} {{base-roll-fifteen=[[1d6]] }} {{base-roll-sixteen=[[1d6]] }} {{base-roll-seventeen=[[1d6]] }} {{base-roll-eighteen=[[1d6]] }}
!roll20AM --nomenu,audio,play|?{Sound|Cry, face02cry|Final Embrace, face03finalemb}


edit - see below for corrected code. derp.

January 22 (3 weeks ago)
Paul
Pro

Here's another example modifying a token action for the xenomorph's Acid Splash. This is modified with a custom visual fx and a sound fx tagged on the end. I also stuck a query in the code to account for a dice pool modification used by the attack and changed to {selected} so I can easily transfer it.


@{Selected|roll_command} &{template:alien} {{character-name=@{Selected|character_name} }} {{roll-name=Acid Splash }} {{base-dice=[[@{Selected|acidsplash} + ?{Damage:}]] }} {{base-roll-one=[[1d6]] }} {{base-roll-two=[[1d6]] }} {{base-roll-three=[[1d6]] }} {{base-roll-four=[[1d6]] }} {{base-roll-five=[[1d6]] }}  {{base-roll-six=[[1d6]] }} {{base-roll-seven=[[1d6]] }} {{base-roll-eight=[[1d6]] }} {{base-roll-nine=[[1d6]] }} {{base-roll-ten=[[1d6]] }} {{base-roll-eleven=[[1d6]] }} {{base-roll-twelve=[[1d6]] }} {{base-roll-thirteen=[[1d6]] }} {{base-roll-fourteen=[[1d6]] }} {{base-roll-fifteen=[[1d6]] }} {{base-roll-sixteen=[[1d6]] }} {{base-roll-seventeen=[[1d6]] }} {{base-roll-eighteen=[[1d6]] }}
/fx acidbomb
!roll20AM --nomenu,audio,play|acidsplash
January 24 (3 weeks ago)

Edited January 24 (3 weeks ago)
Paul
Pro

Well crap - actually the attack code wasn't randomizing it, clearly only pulling the third attack. I managed to get the much simpler code below to do what I needed, as Tuo suggested. lol. It's weird because I had already tried this without success but now it works.


%{Facehugger|randomizeattackaction}
!roll20AM --nomenu,audio,play|?{Sound|Cry, face02cry|Final Embrace, face03finalemb}


edit - well that worked and now it doesn't for apparently no reason. It still rolls the random attack but it stopped querying for a sound and doesn't play the sound, it ignores the second command completely; it had worked though. fuudge.

January 24 (3 weeks ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

You might want to try the Simple Sound mod. There's a lot fewer moving parts to it.

January 24 (2 weeks ago)
timmaugh
Pro
API Scripter

Also, ZeroFrame batching for multi-command macros. It can help with those lines getting dropped/ignored.