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

API Inspiration tracker status

API wont work or needs updating for the OGL sheet  installed via drop down i am attempting to use the  inspiration tracker api  how ever the get brightness is no longer defined according to the error anyway  Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: ReferenceError: getBrightness is not defined ReferenceError: getBrightness is not defined at AnnounceInspiration (apiscript.js:3913:35) at apiscript.js:3963:25 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:909:14) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1378:11 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)
I've got the same issue. 
1520952732
The Aaron
Pro
API Scripter
see if this works for you: //HazInspiration v. 0.2 created&nbsp; on the 9-27-2017 by Giger, my first script with massive help from TheAaron and code shamelessly stolen from Sky's Initiative System (it's pretty) /* &nbsp; &nbsp; This script reports to the chat window, and updates the players token with an icon, to indicate whether the player has Inspiration or not. &nbsp; &nbsp; Designed for the 5th Edition ( OGL by Roll20 ) Character Sheet. &nbsp; &nbsp;&nbsp; */ &nbsp; &nbsp; &nbsp; on('ready',()=&gt;{ &nbsp; &nbsp; &nbsp; const getCharacterTokens = (cid) =&gt; findObjs({type:'graphic'}).filter((t)=&gt;t.get('represents')===cid); &nbsp; &nbsp; &nbsp; //Brightness&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var getHex2Dec = function(hex_string) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hex_string = (hex_string + '').replace(/[^a-f0-9]/gi, ''); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return parseInt(hex_string, 16); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var getBrightness = function (hex) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hex = hex.replace('#', ''); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var c_r = getHex2Dec(hex.substr(0, 2)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var c_g = getHex2Dec(hex.substr(2, 2)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var c_b = getHex2Dec(hex.substr(4, 2)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; const announceInspiration = function (id) { &nbsp; &nbsp; &nbsp; //Handles Chat Annoucement &nbsp; &nbsp; &nbsp; if ( _.isEmpty(id)) return; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var character = getObj("character", id); &nbsp; &nbsp; &nbsp; var AlertTokenName = character.get("name"); &nbsp; &nbsp; &nbsp; var AlertColor = getObj("player", character.get("controlledby").split(",")[0]).get("color"); &nbsp; &nbsp; &nbsp; var AlertTextColor = (getBrightness(AlertColor) &lt; (255 / 2)) ? "#FFF" : "#000"; &nbsp; &nbsp; &nbsp; var AlertShadowColor = (AlertTextColor == "#000") ? "#FFF" : "#000"; &nbsp; &nbsp; &nbsp; var AlertOuterStyle = "max-height: 40px; width: 100%; margin: 10px 0px 5px -7px; line-height: 40px;"; &nbsp; &nbsp; &nbsp; var AlertInnerStyle = "max-height: 20px; width: 100%; margin: 0px; padding: 0px 0px 2px 0px; clear: both; overflow: hidden; font-family: Candal; font-weight: lighter; font-size: 13px; line-height: 20px; color: " + AlertTextColor + "; background-color: " + AlertColor + "; background-image: linear-gradient(rgba(255, 255, 255, .4), rgba(255, 255, 255, 0)); border: 1px solid #000; border-radius: 4px; text-shadow: -1px -1px 0 " + AlertShadowColor + ", 1px -1px 0 " + AlertShadowColor + ", -1px 1px 0 " + AlertShadowColor + ", 1px 1px 0 " + AlertShadowColor + ";"; &nbsp; &nbsp; &nbsp; var AlertImageStyle = "height: 40px; width: 40px; float: right; margin: -32px 5px 0px 0px;"; &nbsp; &nbsp; &nbsp; sendChat("", "/desc &lt;div style='" + AlertOuterStyle + "'&gt;&lt;div style='" + AlertInnerStyle + "'&gt;" + AlertTokenName + " is Inspired! &lt;/div&gt;&lt;img src='<a href="https://s3.amazonaws.com/files.d20.io/images/39783029/-w45_4ICV9QnFzijBimwKA/max.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/39783029/-w45_4ICV9QnFzijBimwKA/max.png</a>' style='" + AlertImageStyle + "'&gt;&lt;/img&gt;&lt;/div&gt;"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Set Status Icon on Token &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getCharacterTokens(character.id).forEach((t)=&gt;t.set('status_black-flag',true)); &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; const dropInspiration = function (id) { &nbsp; &nbsp; &nbsp; //Remove Status Icon from Token &nbsp; &nbsp; &nbsp; if ( _.isEmpty(id)) return; &nbsp; &nbsp; &nbsp; var character = getObj("character", id); &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; getCharacterTokens(character.id).forEach((t)=&gt;t.set('status_black-flag',false)); &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; on("chat:message", function(msg) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Is script running? &nbsp; &nbsp; &nbsp; if(msg.type == "api" && msg.content.indexOf("!inspiration") !== -1) {&nbsp; &nbsp; &nbsp; &nbsp; sendChat("", "/desc &lt;div style='max-height: 40px; width: 100%; margin: 10px 0px 5px -7px; line-height: 40px;'&gt;&lt;div style='max-height: 20px; width: 100%; margin: 0px; padding: 0px 0px 2px 0px; clear: both; overflow: hidden; font-family: Candal; font-weight: lighter; font-size: 13px; line-height: 20px; color: fff; background-color: 20b2aa; background-image: linear-gradient(rgba(255, 255, 255, .4), rgba(255, 255, 255, 0)); border: 1px solid #000; border-radius: 4px; text-shadow: -1px -1px 0 000, 1px -1px 0 000, -1px 1px 0 000, 1px 1px 0 000'&gt;Inspiration Tracking Online!&lt;/div&gt;&lt;/div&gt;"); &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; // Has a character sheet been updated? &nbsp; &nbsp; &nbsp; on("change:attribute", function(obj) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var isupdated = obj.get("name"); &nbsp; &nbsp; &nbsp; //Was it the Inspiration attribute? &nbsp; &nbsp; &nbsp; if (isupdated =="inspiration"){ &nbsp; &nbsp; &nbsp; var val = obj.get("current"); &nbsp; &nbsp; &nbsp; var id = obj.get("_characterid");&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; //Gained Inspiration? &nbsp; &nbsp; &nbsp; if (isupdated =="inspiration" && val == "on"){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Announce Character Inspired &nbsp; &nbsp; &nbsp; announceInspiration(id); &nbsp; &nbsp; &nbsp; }else if (isupdated =="inspiration" && val != "on"){ &nbsp; &nbsp; &nbsp; //Remove Inspiration Icon from Token &nbsp; &nbsp; &nbsp; dropInspiration(id); &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; log('-=&gt; HazInspiration &lt;=- V0.2');&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; sendChat("", "/desc &lt;div style='max-height: 40px; width: 100%; margin: 10px 0px 5px -7px; line-height: 40px;'&gt;&lt;div style='max-height: 20px; width: 100%; margin: 0px; padding: 0px 0px 2px 0px; clear: both; overflow: hidden; font-family: Candal; font-weight: lighter; font-size: 13px; line-height: 20px; color: fff; background-color: 20b2aa; background-image: linear-gradient(rgba(255, 255, 255, .4), rgba(255, 255, 255, 0)); border: 1px solid #000; border-radius: 4px; text-shadow: -1px -1px 0 000, 1px -1px 0 000, -1px 1px 0 000, 1px 1px 0 000'&gt;Inspiration Tracking Online!&lt;/div&gt;&lt;/div&gt;"); &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; });
that did it :D as always The Aaron to the Rescue&nbsp;
1521324775
The Aaron
Pro
API Scripter
Sweet. =D