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

[Script] Snippet: PageSound

November 12 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

This is a tiny little snippet. I wanted an audio notification for the players when a page changes. It makes for a nice presentation and cues their attention. This script will play a sound from your jukebox whenever you move the player flag. If there is a jukebox track already associate with the page, that track will play instead of the script track.

To use it, replace the title definition below from 'Page Load' to the name of the track you want. Spelling and capitalization must be exact. The script will make a log message if the track name is incorrect or missing, but otherwise, it will make no in-game fuss.

One last thing: choose a short sound. If the track has not finished before you move the page flag again, the sound will not restart.

Here is a little video of it in action.


   on('change:campaign:playerpageid', function() {
       let track = findObjs({
           type: 'jukeboxtrack',
           title: 'Page Load'
       })[0];
       if (track) {
           track.set('softstop', false);
           track.set('playing', true);
       } else {
           log('PageSound cannot find track. Check to make sure spelling is correct');
       };
   });



November 13 (1 year ago)
timmaugh
Forum Champion
API Scripter

Nice one, Keith!