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

Help with LazyExperience

So, I've been testing out some API scripts for my Tomb of Annihilation campaign, and whenever I add XP to an individual player with LazyExperience, I get the following error:   TypeError: Cannot read property 'characters' of undefined TypeError: Cannot read property 'characters' of undefined at setExperience (apiscript.js:836:48) at handleInput (apiscript.js:693:25) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:151:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:151:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1634: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) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400 Anyone know what's going on here? I don't know if this is a bug in LazyExperience, or if maybe another script is somehow interfering with it? I've tried disabling other scripts to see if anything is incompatible, and it keeps on happening.
1530885060
The Aaron
Pro
API Scripter
This is an error in LazyExperience: setExperience = (experience, characterid) => { let playerid; if(characterid){ playerid = findObjs({ _id: characterid, _type: 'character' }).shift().get('controlledby'); state[state_name].players[playerid].characters.forEach((character, i) =>{ if(character.id === characterid){ state[state_name].players[playerid].characters[i].experience += experience; } }) }else{ state[state_name].session_experience += experience; } It assumes that a character is controlled by only one player and that player is not the 'all' player.  I'd guess that one of your characters is controlled by multiple players, the all player, or no player at all.
Thank you! I’ll go through and fix everyone’s  sheet permissions.
1530887934
The Aaron
Pro
API Scripter
Yeah, hopefully Robin will fix that bug.  Hope that works for you and if it's still broken, come back and we'll try again. =D
For some reason (likely a PEBCAK issue), I had myself listed in the "controlled by" field for all the characters. Once I took myself off the list, everything worked perfectly.
1530895222
The Aaron
Pro
API Scripter
Great!  Good to have confirmation that you got it working AND what the actual issue was.  That will make it much easier to fix, thanks!