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

Miss Represented

I spent the last 2 days trying to figure out why the following (familiar to all) code snippet was giving undefined for  oCharacter. selected, and oToken existed.  _.each(selected, function(obj) {  if (obj._type != "graphic") {return;}; var oToken = getObj("graphic", obj._id); var oCharacter = getObj("character", oToken.get("represents")); something_found = oCharacter.get("name"); }); Wrote rewrote read and reread cried and recried.  What was happening was that I have not associated the token a character sheet. So there was nothing to "represents" the error was not in the code but in a misstep in setting up the tokens. I will add a check somewhere in there to hopefully catch this potential user error (me the user) in the future.  Now I can move on to cry over other things. 
1459422673
The Aaron
Pro
API Scripter
I feel your pain. I can't count the number of times I've written: var t=getObj('graphic', o.id); and said "why is nothing selected!?!? Using lots of log() statements to verify assumptions can help you track down those things, but definitely don't wait until you're complete frazzled before posting. There are many people on this forum that will be happy to help you spot issues or help debug. 
I use more logs than a lumberyard, and I am inching towards comprehending the help that is given. lol