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

Issue with undefined of undefined.

1590105778
Mik H.
Forum Champion
Trying to make up a records page for the Pathfinder2e Extinction Curse circus.&nbsp; I've created a bunch of tokens on the GM layer, each named for certain fields on the sheet. The goal is to be able to create text fields that I can identify and move around when needed. I've hit a strange roadblock - I keep getting an error "TypeError: Cannot set property 'undefined' of undefined" at a random point while iterating through the token graphics. It will successfully go through a dozen or so graphics before crashing and throwing that error, and the strangest thing is that moving the tokens and trying again will cause it to crash at a different point.&nbsp; I'm not certain exactly what to do here. My (currently broken) code is&nbsp; <a href="https://github.com/Mikkles/roll20api/blob/master/CircusHelper.js" rel="nofollow">https://github.com/Mikkles/roll20api/blob/master/CircusHelper.js</a> If anyone has any input, I would definitely appreciate it.&nbsp;
1590123502
The Aaron
Roll20 Production Team
API Scripter
There are a few things. I'm on my phone and full of wine, so this will be a bit terse... textIDs: [] This is an array, so will be indexed by integers. This: _.each(state.Circus.textIDs, function(current) { textList[current] = getObj('text', state.Circus.textIDs[current]); }) Is referencing it with a string. current will be the value, not the index. So the ID, not the name. That probably doesn't matter because this line will wipe out textList before you use it: textList = {}; This will again use a string to index the array: state.Circus.textIDs[name] = thisID; Fixing those will probably help. I'll look more tomorrow...
1590135005
Mik H.
Forum Champion
You are beyond amazing, Aaron. That helped me understand how things are referenced; I was mostly just copying code and trial by error without understanding. Making the state hold a simpler object of {key: name string, value: id string} worked perfectly. I've updated the code with a mostly-working build. It still requires very specific tokens to already be on the map, but in my next rework I'll try and get rid of that requirement.
1590178118
The Aaron
Roll20 Production Team
API Scripter
Great!&nbsp; Sorry if that was a bit stream of consciousness. =D&nbsp; I'll take a look at the code later and see if I can get you some more feedback. =D