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

'.set' for 'jukeboxtrack' Type Objects

1505161833

Edited 1505161896
I've been trying to re-engineer&nbsp; this particular ammo script (by Aaron C. M.) in order to automatically play a sound effect when ammo is used or ammo is depleted. The concept is simple. With the use of one macro for an already existing script, be able to fire a weapon if it has ammo and play the appropriate sound effect. If it is out of ammo, deny the user the ability to deplete ammo below zero and play the 'out of ammo' sound effect. Both sound effects are determined by the command's parameters !ammo @{selected|token_id} weapon1Ammunition -1 __m9_1 ammo_out "__m9_1" is the name of the sound for the gun firing "ammo_out" is the name of the sound for, well... you know. The Problem I've gone back and forth trying to recreate the way the Audio Master and SFX scripts do it, but it doesn't seem to be recognizing the 'jukeboxtrack' object. The log outputs "[object Object]" as the music object that's trying to get played. ultimately, I want to turn a string, into a music object, that gets played once. <a href="https://www.dropbox.com/s/k3v1rd6kbi9iini/ammo.js?dl=0" rel="nofollow">https://www.dropbox.com/s/k3v1rd6kbi9iini/ammo.js?dl=0</a> These are the errors I'm getting in the current iteration. <a href="https://pastebin.com/9aE2f1uW" rel="nofollow">https://pastebin.com/9aE2f1uW</a>
1505164540
The Aaron
Pro
API Scripter
The "Play function, song is [object Object] " Is just because of the way output is encoded, try replacing your log call with this: &nbsp; &nbsp; &nbsp; &nbsp; log('Play function, song is '+song.get('title')+' '); or log('Play function, song is '+JSON.stringify(song)+' '); As to that other issue, it's because you're passing the song object to itself: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; song.set({ &nbsp;playing: true, softstop: false, title:song }); Which makes for a problem. &nbsp;Just don't do that. &nbsp;It's probably a typo anyway: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; song.set({ &nbsp;playing: true, softstop: false}); Hope that helps!
Did the trick, thanks! Now I just need to work out a little bug with where the boolean flags are and I'll post the solution.