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

Get APL script stopped working

Hey anyone have an idea why this script would have worked last week but not this week? var getAPL = getAPL || (function() { 'use strict'; var version = 1.1, checkInstall = function() { log('getAPL v'+version+' is ready! Designed for 5e AL APL Calculation'); }, isLevel = function(id) { var isLevel = findObjs({_type: 'attribute', _characterid: id, name: 'level'}); if (_.isUndefined(isLevel[0])) { return false; } else { return isLevel[0].get('current'); } }, getSelectedCharacters = function(selected) { return _.chain(selected) .map(function(s){ return getObj(s._type,s._id); }) .reject(_.isUndefined) .map(function(c){ return getObj('character', c.get('represents')); }) .filter(_.identity) .value(); }, round = function(value, decimals) { return Number(Math.round(value+'e'+decimals)+'e-'+decimals); }, partyStr = function(partySize, targetAPL, currAPL) { if ((partySize > 2 && partySize < 5) && currAPL < targetAPL) { return "Very weak" } else if ((partySize >= 3 && partySize <= 4) && currAPL == targetAPL) { return "Weak" } else if ((partySize >= 3 && partySize <= 4) && currAPL > targetAPL) { return "Average" } else if (partySize == 5 && currAPL < targetAPL) { return "Weak" } else if (partySize == 5 && currAPL == targetAPL) { return "Average" } else if (partySize == 5 && currAPL > targetAPL) { return "Strong" } else if ((partySize >= 6 && partySize <= 7) && currAPL < targetAPL) { return "Average" } else if ((partySize >= 6 && partySize <= 7) && currAPL == targetAPL) { return "Strong" } else if ((partySize >= 6 && partySize <= 7) && currAPL > targetAPL) { return "Very Strong" } }, handleInput = function(msg) { var args; var char; var players; try { players = msg.selected.length } catch (e) { players = 0 } if (msg.type !== "api") { return; } args = msg.content.split(/\s+/); if(args[0].toLowerCase() == "!getapl") { char = _.uniq(getSelectedCharacters(msg.selected)); var selTot = "0" _.each(char, function(a) { if (isLevel(a.id) !== "0") { selTot = Number(selTot) + Number(isLevel(a.id)) } }); if (players == 0) { sendChat ("getAPL", "/w "+msg.who+" **No Tokens Selected, try again.**"); } else if (players < 3 || players > 7) { sendChat ("getAPL", "/w "+msg.who+" **Not AL Legal** (less than 3 or more than 7) - please check your token selection and try again.") } else if (_.range(1,21).includes(parseInt(args[1],10)||0)) { sendChat ("getAPL", "/w "+msg.who+" **"+players+"** Players at APL: **"+round(selTot/players,0)+"** (**"+partyStr(players,args[1],round(selTot/players,0))+"**) - Target APL: **"+args[1]+"**.") } else { sendChat ("getAPL", "/w "+msg.who+" **"+players+"** Players at APL: **"+round(selTot/players,0)+"**.<br /><em>Try adding your target APL to the end for more information such as:</em><br />**!getAPL 3**") } } }, registerEventHandlers = function() { on('chat:message', handleInput); }; return { CheckInstall: checkInstall, RegisterEventHandlers: registerEventHandlers }; }()); on('ready',function(){ 'use strict'; getAPL.CheckInstall(); getAPL.RegisterEventHandlers(); });
1552942205
The Aaron
Roll20 Production Team
API Scripter
Are you getting an error?
Nope. there is no response in chat, or API sandbox
must be something with the one game as the other one I use it in still works....
1552947989
Kraynic
Pro
Sheet Author
Have you gone to settings and restarted the api for the game you are having trouble with?  It may not be running.  I've had that happen a time or 2, so maybe worth a check.
Yep, even deleted the script and reinstalled it.  Kraynic said: Have you gone to settings and restarted the api for the game you are having trouble with?  It may not be running.  I've had that happen a time or 2, so maybe worth a check.
Do you have other API scripts running? If so try disabling them all except this one.
Still no response from the app. it does say "getAPL v1.1 is ready!  Designed for 5e AL APL Calculation" in the sandbox Rabulias said: Do you have other API scripts running? If so try disabling them all except this one.
All other scripts work fine as well.
1552963839
GiGs
Pro
Sheet Author
API Scripter
Try creating a new campaign, and install it as the only script. See if it works then.
Yep works in new and other games I have, copied the game over and just added that script and it did work in that one ether. It must be something with that one game.
figured out it works still in firefox  just not in chrome for this one game.  weird....
1553549641
GiGs
Pro
Sheet Author
API Scripter
You might want to raise that as a bug, stating the name of the campaign that is acting weirdly in your bug report.