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 .
×

TurnTracker1 - Spell Durations and Effects Help

I realize I'm late for this band wagon but I'm hoping I can get some help. I added the script from the previous forum to my game but, when I use it, it adds 2 of whatever I requested. I don't know enough about script to figure out why it is doing that; I'm hoping someone can help figure out why it adds two at once instead of just one.  Copy of the script I copied: on('ready',function(){     "use strict";     const checkFormulaOnTurn = () => {         let to=JSON.parse(Campaign().get('turnorder')||'[]');         if(to.length && to[0].id==='-1'){             sendChat('',`[[${to[0].pr}+(${to[0].formula||0})]]`,(r)=>{                 to[0].pr=r[0].inlinerolls[0].results.total;                 Campaign().set('turnorder',JSON.stringify(to));             });         }     };     on('chat:message',function(msg){         var args,cmds,who,initial,change,entry;         if('api' === msg.type) {             if(msg.content.match(/^!act\b/) ){                 who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');                 if(_.has(msg,'inlinerolls')){                     msg.content = _.chain(msg.inlinerolls)                         .reduce(function(m,v,k){                             var ti=_.reduce(v.results.rolls,function(m2,v2){                                 if(_.has(v2,'table')){                                     m2.push(_.reduce(v2.results,function(m3,v3){                                         m3.push(v3.tableItem.name);                                         return m3;                                     },[]).join(', '));                                 }                                 return m2;                             },[]).join(', ');                             m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0;                             return m;                         },{})                         .reduce(function(m,v,k){                             return m.replace(k,v);                         },msg.content)                         .value();                 }                 args = msg.content                     .replace(/<br\/>\n/g, ' ')                     .replace(/(\{\{(.*?)\}\})/g," $2 ")                     .split(/\s+--/);                 cmds=args.shift().split(/\s+/);                 change=parseFloat(cmds[1])||'+1';                 change=`${/^[+-]\d/.test(change)?'':'+'}${change}`;                 initial=parseFloat(cmds[2])||0;                 entry=args.join(' ');                 if(entry.length){                     let to=JSON.parse(Campaign().get('turnorder')||'[]');                     to.unshift({                         id: "-1",                         pr: initial,                         custom: entry,                         formula: change                     });                     Campaign().set('turnorder',JSON.stringify(to));                     if(!playerIsGM(msg.playerid)){                         sendChat('ACT',`/w gm <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;"><b>${who}</b> added entry for <b>${entry}</b> starting at <b>${initial}</b> and changing by <b>${change}</b>.</div></div>`);                     }                 } else {                     sendChat('ACT',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Use <b><pre>!act [formula] [starting value] --[description]</pre></b></div></div>`);                 }             } else if(msg.content.match(/^!eot/i)){                 _.defer(checkFormulaOnTurn);             }         }     }); }); I'm running my first session in probably 2-3 weeks, so would love help before that happens. Thanks in advance to any and all help! 
I'm not sure if it is what you are looking for, but for spell duration at least, it might be worth looking at the AddCustomTurn mod in API/Mod library, you did mention a previous forum post, but I couldn't see any sign of anything here. I use the mod for tracking spell or feature times as it will count down the timer for a spell or feature as you cycle through the turn order.  I thought I'd mention it as it may do at least some of what you want, and having been written by The Aaron, you can pretty much guarantee it will work perfectly.
1663849938
timmaugh
Roll20 Production Team
API Scripter
Couple of things to look for... Do you have this script copied in multiple times? Each standard script answers a particular handle -- this one looks like it answers !act... -- but that doesn't mean *other* scripts can't also answer that. So if you have this code copied in twice, they will both answer and both add an item to the turnorder. To really test this, you'll need to not only look at the tabs in your script panel, but maybe look to see if you have double-pasted the code onto the appropriate tab, or inadvertently posted it on another tab (at the bottom of the script that should be there). All scripts are rolled up into a single, long file when the sandbox boots, so having multiple scripts on a single panel in  your script deck is functionally the same to having them on separate panels. I would suggest disabling the script tab/entry/panel for this script and let the sandbox reboot. Then try the same command to try to trigger the script. Does something still happen? Then the code exists somewhere else in your library. Another thing to consider is that immediately after rebooting your sandbox, you actually have 2 sandboxes running... the previous one doesn't entirely shut down as quickly as the second boots up... so if you dispatch a command straightaway after you sandbox loads you will sometimes get a double response. Wait 10-15 seconds after the sandbox is "ready" to allow the old instance to close.
1663857535
The Aaron
Roll20 Production Team
API Scripter
My guess is you have this script and AddCustomTurn both installed. AddCustomTurn I'm the Mods Library is actually an enhancement of this script, so they share the same command and functionality. 
AddCustomTurn had already been added but I wasn't aware due to my codm already adding that in for me. Thank you all for the help!