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

Avatar of Woah's Macro list - script by TheAaron crashing

So, I'm fairly new to a lot of this - but.. have figured out a bunch of stuff and love all of the incredible features and hard work people have put into this. (I can build networks, but I can't code my way out of a wet paper bag.) That said, I'm scavenging bits and pieces for automation, and I think I've got most of what I'm looking at working..&nbsp; The below list looks pretty amazing : <a href="https://app.roll20.net/forum/post/4146463/fantasti" rel="nofollow">https://app.roll20.net/forum/post/4146463/fantasti</a>... I think I understand most of it - except the 'Combat' section.&nbsp; I've added the two scripts as indicated, and pasted the Macro's.&nbsp; When I click the 'Combat' Macro - I don't get the expected whisper into chat. I get a popup asking me to pick a track - once I select it, THEN i get the whisper - but I also get this API error: TypeError: Cannot read property 'set' of undefined TypeError: Cannot read property 'set' of undefined at PlaySound (apiscript.js:16475:6) at apiscript.js:16490:1 at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:146:1), &lt;anonymous&gt;:70:8) at /home/node/d20-api-server/api.js:1510:12 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) at Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) I'm using (and loving) the other scripts...&nbsp; Well, except for the fact that 'ItsATrap' seems to be putting its wizard button into ALL of my token action bars, and I'm not sure where I did that - but I can work through that. As a separate not, i tried to go back to the google doc to recopy the sound-on-tap script that Woah posted, but suddenly the 'suggestion' on the side is gone - I'm wondering if TheAaron has that script posted somewhere else? &nbsp;(I tried looking but he has 50 bajillion posts and I only have so many hours in a week...)
1494048714

Edited 1494048743
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi Drew, Welcome to Roll20, Drew T. said: So, I'm fairly new to a lot of this - but.. have figured out a bunch of stuff and love all of the incredible features and hard work people have put into this. (I can build networks, but I can't code my way out of a wet paper bag.) That said, I'm scavenging bits and pieces for automation, and I think I've got most of what I'm looking at working..&nbsp; The below list looks pretty amazing : <a href="https://app.roll20.net/forum/post/4146463/fantasti" rel="nofollow">https://app.roll20.net/forum/post/4146463/fantasti</a>... I think I understand most of it - except the 'Combat' section.&nbsp; I've added the two scripts as indicated, and pasted the Macro's.&nbsp; When I click the 'Combat' Macro - I don't get the expected whisper into chat. I get a popup asking me to pick a track - once I select it, THEN i get the whisper - but I also get this API error: TypeError: Cannot read property 'set' of undefined [Removed for Length] The query pops up first because queries are resolved before chat messages are sent to the chat parser, so this is the expected behavior. I'm not sure which of the couple audio scripts you're using (don't recognize the function calls), but I'd guess you are trying to pass it an invalid track name and it doesn't have adequate gating to weed out erroneous calls like that. I'm using (and loving) the other scripts...&nbsp; Well, except for the fact that 'ItsATrap' seems to be putting its wizard button into ALL of my token action bars, and I'm not sure where I did that - but I can work through that. You can go into your collections tab and uncheck the token action option for It's a Trap's wizard macros to take care of this. As a separate not, i tried to go back to the google doc to recopy the sound-on-tap script that Woah posted, but suddenly the 'suggestion' on the side is gone - I'm wondering if TheAaron has that script posted somewhere else? &nbsp;(I tried looking but he has 50 bajillion posts and I only have so many hours in a week...) Aaron is indeed a prolific script author. I don't believe that !playsound script is his though; regardless, I'd recommend looking at my&nbsp; Roll20 Audio Master script&nbsp; as it can handle just about anything jukebox related you need to do. Let me know if you've got any other questions, Scott
Yeah.. I thought it was failing on finding the track as well - but that isn't it. (according to Woah's google doc, the script is from Aaron). There's logic in the script which I can see to print a 'track not found' message - it looks like the API is failing when the script is called - whole bunch of firebase errors. I did see your audio master , but this script looks like it should be much simpler... I have *zero* script knowledge to understand why its failing. Its a small script: on('ready', function(){ 'use strict'; var PlaySound = function(trackname, time) { var track = findObjs({type: 'jukeboxtrack', title: trackname})[0]; track.set('playing',false); track.set('softstop',false); if(track) { track.set('playing',true); } else { log("No track found"); } }; on("chat:message", function(msg) { var match; if('api' === msg.type) { match = msg.content.match(/^!playsound\s+(.*)$/); if(match && match.length&gt;1) { PlaySound(match[1]); } } }); }); It doesn't seem to like 'set' - but.. again, with my lack of scripting skills, i'm guessing wildly...
1494078104
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
No problem, scripts can be a bit intimidating when you first start using them. I've got some ideas for your problem though. Move these two lines: track.set('playing',false); track.set('softstop',false); inside the if(track){...: if(track) { track.set('playing',false); track.set('softstop',false); track.set('playing',true); } else { log("No track found"); } I think it wasn't finding a track of that name, and so would then crash at the first of those lines. I would also change the track finding line to prevent a potential crash there. Final code with all my suggested changes: on('ready', function(){ 'use strict'; var PlaySound = function(trackname) { var track = _.find(findObjs({type: 'jukeboxtrack'}),(t)=&gt;{return t.get('name')===trackname}); if(track) { track.set('playing',false); track.set('softstop',false); track.set('playing',true); }else { log("No track found"); } }; on("chat:message", function(msg) { var match; if('api' === msg.type) { match = msg.content.match(/^!playsound\s+(.*)$/); if(match && match.length&gt;1) { PlaySound(match[1]); } } }); }); A good way to see if this was the problem with the original code is to disable all your other scripts and then try the !playsound command (with the original code) and see what the line numbers referenced are.
Well.. the sandbox doesn't crash with your version.. and if I select a track that isn't in my jukebox, it does output 'no track found' - but it doesn't play a sound either... I'm not sure the macro is working properly either in any case, so.. time for some more digging.
Ok - I don't know the the difference is. If I move the two lines in the original script as you suggested it works. your suggested code finds no tracks, regardless of name.... however - the macro is *working*. ;)
1494083278
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmmm, ok, try this: on('ready', function(){ 'use strict'; var PlaySound = function(trackname) { var track = _.find(findObjs({type: 'jukeboxtrack'}),(t)=&gt;{return t.get('name')===trackname}); if(track) { track.set('playing',false); track.set('softstop',false); _.defer(()=&gt;{track.set('playing',true)}); }else { log("No track found"); } }; on("chat:message", function(msg) { var match; if('api' === msg.type) { match = msg.content.match(/^!playsound\s+(.*)$/); if(match && match.length&gt;1) { PlaySound(match[1]); } } }); });