Well, uh.... Turns out even just getting the HP and SP bar to spawn is a problem. It shouldn't have been too hard, just gotta make it work like the background bar and it's all fine, right? Guess I was wrong. on('ready',function(){ "use strict"; var leftOffset = 20, topOffset = 30, // creates a background object and adds relationship to the state addBackgroundBar = function(obj){ if(!_.has(state.maneater.tokens,obj.id)){ let bg=createObj('graphic',{ pageid: obj.get('pageid'), imgsrc: '<a href="https://s3.amazonaws.com/files.d20.io/images/18365129/ouWda8s3smxFGrIMd3GenA/thumb.png?1461339104" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/18365129/ouWda8s3smxFGrIMd3GenA/thumb.png?1461339104</a>', left: obj.get('left')+leftOffset, top: obj.get('top')+topOffset, width: 120, height: 30, rotation: -15, layer: 'objects' })}; addHPBar = function(obj){ if(!_.has(state.maneater.tokens,obj.id)){ let hp=createObj('graphic',{ pageid: obj.get('pageid'), imgsrc: '<a href="https://s3.amazonaws.com/files.d20.io/images/18365209/DnbjiCaANIFZ9lC-IIItRg/med.png?1461339385" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/18365209/DnbjiCaANIFZ9lC-IIItRg/med.png?1461339385</a>', left: obj.get('left')+leftOffset, top: obj.get('top')+topOffset, width: 120, height: 30, rotation: -15, layer: 'objects' })}; state.maneater.tokens[obj.id]={ /* indexed by the token id for easy lookup */ tokenID: obj.id, /* token's id, useful to store here as well as the index */ bgID: bg.id, /* id of the background image created for this token */ hpID: hp.id }; } }, /* updated the background image for this token */ updateBackgroundBar = function(obj){ // checks to see if there is a relationship in the state (eventually, you won't want to add these to everything...) if(_.has(state.maneater.tokens,obj.id)){ // gets the associated background image let bg=getObj('graphic',state.maneater.tokens[obj.id].bgID); // repositions it relative to the token bg.set({ left: obj.get('left')+leftOffset, top: obj.get('top')+topOffset }); } }; updateHPBar = function(obj){ if(_.has(state.maneater.tokens,obj.id)){ let hp=getObj('graphic',state.maneater.tokens[obj.id].hpID); hp.set({ left: obj.get('left')+leftOffset, top: obj.get('top')+topOffset }); } }; // initializer for the state property maneater if(!_.has(state,'maneater')){ state.maneater={ tokens: {} }; } // catch the creation of graphics on('add:graphic', addBackgroundBar ); on('add:graphic', addHPBar ); // catch the changing of graphics on('change:graphic', updateBackgroundBar ); on('change:graphic', updateHPBar ); }); I thought this would've worked, but sadly even just saving the code brings forth this. ReferenceError: updateHPBar is not defined
at Object. (apiscript.js:1511:15)
at eval (eval at (/home/node/d20-api-server/api.js:105:34), :65:16)
at Object.publish (eval at (/home/node/d20-api-server/api.js:105:34), :70:8)
at checkForReady (/home/node/d20-api-server/api.js:982:12)
at /home/node/d20-api-server/api.js:1061:9
at c (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:14:64)
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 Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) So, uh, crap. It seems it doesn't recognize the updateHPBar as defined or something.