keithcurtis said: Try this: 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('Damage Sound', '/w gm No Track Found...'); log("No track found " + trackname); } } on("change:graphic:bar1_value", function (obj, prev) {
//Define Sound Lists
const downSounds = ["ouch", "bam", "smash", "pow", "thud", "argh", "wilhelm_scream"];
const upSounds = ["yay", "heal", "cheer", "not_today", "good", "stand_up", "I_feel_better"];
const downRandom = Math.floor(Math.random() * downSounds.length);
const upRandom = Math.floor(Math.random() * upSounds.length);
//Bar goes down if (prev.bar1_value > obj.get("bar1_value")) {
playSound(downSounds[downRandom], 'play'); }
// Bar goes up
if (prev.bar1_value < obj.get("bar1_value")) {
playSound(sounds[upRandom], 'play'); }
});
});
I haven't tested it, but if it gives problems let me know. I re-ordered it a bit to make the sound lists easier to find and edit. It did not seem to work, this is the error message I get. Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your script's code and click the "Save Script" button. We will then attempt to start running the scripts again. More info... If this script was installed from the Mod Library, you might find help in the Community API Forum. For reference, the error message generated was: ReferenceError: sounds is not defined
ReferenceError: sounds is not defined
at apiscript.js:14101:27
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:65:16)
at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:70:8)
at TrackedObj.set (/home/node/d20-api-server/api.js:1099:14)
at updateLocalCache (/home/node/d20-api-server/api.js:1442:18)
at /home/node/d20-api-server/api.js:1628:11
at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560
at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)
at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)
at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489)