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

[Scriptlet] Doornoise

1671737485

Edited 1671737651
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Here's a quick little script I threw together while testing door functionality. It plays a door open noise when you open a door and a close noise when you close it. If the door is hidden, it stays silent. Note that you will have to upload your own jukebox tracks and the names of the tracks and the names in the script will need to match. Roll20 CoC discourages posting files in the forum, so if anyone wants the open-source sound files I'm using, send me a PM. on('ready', () => {     let playSound = function (trackname, action) {         let track = findObjs({ type: 'jukeboxtrack', title: trackname })[0];         if (track) {             track.set('playing', false);             track.set('softstop', false);             if (action == 'play') {                 track.set('playing', true);             }         }         else {             sendChat('Doorsound', '/w gm No Track Found...');             log("No track found " + trackname);         }     }     on("change:door:isOpen", function (obj, prev) {         if (!prev.isSecret) {             if (prev.isOpen) {                 playSound("Door-Close", 'play');             } else {                 playSound("Door-Open", 'play');             }         }     }); });
Wonderful stuff, many thanks  :-)
Brilliant! Thank you for this. Is there a way to play a different/third sound when a player tries to open a door that it is locked? 
1673468624
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There have been requests to expose that change to Mod scripts, but as yet, there is no event trigger for that action.