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 .
×
May your rolls be merry + bright! 🎄
Create a free account

Play a SFX when droping a Token

1618098698

Edited 1618098777
Hey guys, First of all, I have googled my query throughout the forum already - sorry anyways if I'm reviving any discussions around it. Well, basically I'm wondering if there's a way to play a sound effect when droping a Token in the map, like placing a heavy mini upon a wooden table. I'm willing to develop a script myself and share with everyone. However, checking the API docs, I did not find two things that I guesstimate to be needed: - A trigger for JS to know when a token has been placed; - Play a SFX to all users in the table. So, this is basically me calling you out for a brainstorm - no rush here or definitive need for solutions. What do you guys think? :D
1618100600
David M.
Pro
API Scripter
I have never done anything with audio within Roll20, but you can listen for token creation with something as simple as this: on('ready', () => { on("add:graphic", function(obj) { sendChat('', '/w gm Graphic created!') }); }); Maybe you could send a  Roll20AM script  command to the chat instead of just the text I'm outputting above?  
1618149071

Edited 1618149194
That worked like a charm, David. Thank you! So in order to play a SFX on token drop, I'm just calling Matt's Music Control for Tokens  to play an audio, something like this already: on('ready', () => { on("add:graphic", function(obj) { sendChat('', '!sfx volume:100 action:play song:sfx01') }); }); Next step now is to expand this script with a few new ideas I had: I'll add an option to vary volume accordingly to token's size;  I'll add an custom attribute to creatures in journal called "sfx". This will be the sfx name that I want the script to play, so a dragon will drop with a roar as a soldier will drop with a march sound. If there's not such a attribute or it is empty, the script will play a standard one. Any news on that and I'll share ASAP with you guys!
1618153682
David M.
Pro
API Scripter
Great!