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

Mod Scripting Advice

1746726026

Edited 1746726085
Pat
Pro
API Scripter
I'm working with audio tracks, I noted that looking for track objects that are newly added requires either a stop-start of the sandbox or a stop-start of the Campaign - is this broadly how it is? Is there a programmatic way to refresh these objects or their index?  var rawset = findObjs({_type:"jukeboxtrack"}); return rawset;
1746734441
timmaugh
Pro
API Scripter
You should be able to run code that refreshes at any event. Typically, the easiest would be to have a chat event listener to which you could feed a command to have anything refresh. When are you running that line that fills  rawset  with the results of the findObjs() function? Because if you're running that in your on('ready'), or just when the script spins up, it will be filled statically. There is no "socket" connection that will maintain an updated set of returns.
1746746303
Pat
Pro
API Scripter
It's invoked as part of a call to pull up a list of soundtracks to be assigned to "emitters" - tokens that have an audio track specified to play when player tokens are near (on loop)  It's not only invoked on spin-up. The problem I'm having is I started up the game, I added some soundtracks to the game, then I tried to create an emitter - and no soundtracks registered or returned from the call. This call is fired when using the "createEmitter" call to make a token with a particular soundtrack.  It's a simple findObjs call, which should pull up *current*  objects. It consistently doesn't refresh the list that gets pulled up unless I reboot the campaign. 
1746817452
Gold
Forum Champion
Sounds cool. Have you studied on how the Mod script Roll20 Audio Manager did it? This might be similar to what you're asking. I'm not sure if it is. That Mod has a command/feature that "imports all of your Jukebox tracks and playlists into" the Mod.  !roll20AM --config,import
1746833780

Edited 1746836922
Pat
Pro
API Scripter
I think I did this when I was originally working on this - the original was never really finished/fleshed out but the prototype otherwise *is* working in a current Jumpgate game. I'm going to have to go back and look again. The initial import works when tracks are already present in the game, but it doesn't appear to work when re-invoked *during* the game after a track is added. I'm going to create a few use cases to see if the create event for a jukebox object is trackable and can be used to automatically force an import. The audio-attenuation is something I'd like to complete so you can place "environmental" sound that works on repeat. I'm thinking of modifying it to find the center of *all* player tokens and adjust the attenuation based on that.  Edited to add: added in some functions to detect adding or destroying an audio track object. The destroy event fired, the add (create) track event did not. It appears to be, to me, a bug in at least Jumpgate. Tested adding a track completely from scratch (not in my upload list) to see if *that* instead fires the create track event. It did not. Nor did adding it to the game.  Was using wrong event handler, but still having some trouble re-invoking a findObjs function and I'm troubleshooting now.