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

HELP] Lazy Experience error - active/null

I can somewhat parse the information... it can't find the 'Active' property on a null....something. Beyond that, I can't really decipher anything. Has anyone had this error, or is anyone able to provide some insight? API Output Console Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your script's code and click the "Save Script" button. We will then attempt to start running the scripts again. More info... If this script was installed from the Script Library, you might find help in the Community API Forum. For reference, the error message generated was: TypeError: Cannot read property 'active' of null TypeError: Cannot read property 'active' of null     at apiscript.js:498:34     at Array.forEach (<anonymous>)     at getExperienceSharers (apiscript.js:497:64)     at setExperience (apiscript.js:565:73)     at handleInput (apiscript.js:400:29)     at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16)     at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8)     at /home/node/d20-api-server/api.js:1662: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)
1613210765

Edited 1613210811
Oosh
Sheet Author
API Scripter
Here's the getExperienceSharers function causing the problem:      getExperienceSharers  = ()  =>  {          let   xpSharers  =  state [ state_name ]. extra_players * 1 ;          if ( state [ state_name ]. players . length  ===  0 ){  return   xpSharers ; }                   for ( let   playerid   in   state [ state_name ]. players ){              if ( state [ state_name ]. players [ playerid ]. active ){                  state [ state_name ]. players [ playerid ]. characters . forEach (( character )  =>  {                      if ( character . active ){                          xpSharers ++;                     }                 });             }         }          return   xpSharers ;     }, It looks like one of your players has a null character assigned to it. Maybe a character that belonged to a player was deleted? I'm not familiar with the script, is there some way to flush or refresh the player/character lists? Failing that, an extra check in there would stop it from happening again if you're happy to manually run a modified version - change this line: if (character.active) { to if (character && character.active) {
That did it. Thank you. Had a player who made a new character. His old one was still in the journal, but never used, and LazyXP was trying to use the old character for calculations. Removed the character, and just did a full remove/re-add of all players to LazyXP, and it works fine. Thanks!