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

[Pathfinder] Help identifying a console warning

I am receiving a console warning that does not seem to be interfering with the safe operation of any part of my code.  I am concerned that it will become a problem later as I have just imported a large section of code and adapted it for use in my character sheet from the core pathfinder sheet (the Set Buffs, repeating section). I think it has to do with a conflict between the sheet trying to accept Worker calculated values somewhere but not understanding that no valid input  (or output) exists.  My question is, will this code clear up as I continue to work, and if not, where must I look to find the source of this nuisance problem.  I've already converted every readonly="readonly" in the imported code into disabled for testing purposes. Querytest took until 757ms app.js?1509374274:39 Attribute cache compliation took until 758ms app.js?1509374274:39 ERROR parsing formula: undefined app.js?1509374274:39 TypeError: Cannot read property 'replace' of undefined     at T.s.autoCalcFormula (app.js?1509374274:40)     at app.js?1509374274:39     at NodeList.forEach (<anonymous>)     at Function.k.each.k.forEach (base.js?1507671575:1)     at T.s._updateSheetValues (app.js?1509374274:39)     at n (base.js?1507671575:1) app.js?1509374274:39 ERROR parsing formula: undefined app.js?1509374274:39 TypeError: Cannot read property 'replace' of undefined     at T.s.autoCalcFormula (app.js?1509374274:40)     at app.js?1509374274:39     at NodeList.forEach (<anonymous>)     at Function.k.each.k.forEach (base.js?1507671575:1)     at T.s._updateSheetValues (app.js?1509374274:39)     at n (base.js?1507671575:1) app.js?1509374274:39 ERROR parsing formula: undefined app.js?1509374274:39 TypeError: Cannot read property 'replace' of undefined     at T.s.autoCalcFormula (app.js?1509374274:40)     at app.js?1509374274:39     at NodeList.forEach (<anonymous>)     at Function.k.each.k.forEach (base.js?1507671575:1)     at T.s._updateSheetValues (app.js?1509374274:39)     at n (base.js?1507671575:1) app.js?1509374274:39 ERROR parsing formula: undefined app.js?1509374274:39 TypeError: Cannot read property 'replace' of undefined     at T.s.autoCalcFormula (app.js?1509374274:40)     at app.js?1509374274:39     at NodeList.forEach (<anonymous>)     at Function.k.each.k.forEach (base.js?1507671575:1)     at T.s._updateSheetValues (app.js?1509374274:39)     at n (base.js?1507671575:1) I am working in the most recent version of Crome, and as I said the issue does not seem to affect anything else, when I comment out the section of recently imported code (about 1000 lines) the issue vanishes entirely without any trace.  While I DO understand what the error is-- I get them all the time-- I dont understand how or why I'm getting them. Is it possible the issue is coming from the CSS, I cannot see how, but the only part of the code that I cannot get functioning is the buff sorting, and I assumed that the reason that was failing was because it required both CSS and sheetworkers and the Type Selection. Such is always the problem with working with code one doesn't fully understand, but that is the way I learn.  And... *cough* imitation is the highest form of flattery.  Truth be told, I'm not even sure I can get this to function.
1510435321

Edited 1510435492
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It looks like somewhere in the updateSheetValues function you are trying to use .replace on something that is not defined, and furthermore that it is being used as just .replace instead of .replace(regex,string to replace in). Also looks like it is inside an _.each() and is related to a variable k somewhere.
1510436747

Edited 1510436903
Toby
Pro
um.. I dont have anything like that in my sheet workers, thats the issue.  And this issue goes away when I comment out the 1000ish lines of html related to the imported code...  I'm not sure what to make of that, in a debuging sense, except that its not an issue with my code, but something else. I mean, I use _js so infrequently, (i dont understand it well enough), in my code that I know every instance of it, ant what it says.  So, I can tell with absolute certainty there is no variable with "k" in my code.. So, insufficient information to tell if I continue working on the code this will go away on its own?
1510437012
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Do you have a function called updateSheetValues? or is that on the roll20 side? If it's on the roll20 side, then you are passing something invalid to it.
I have no function named updateSheetValues...
I have a direction to look in now though, and at least I know its not with my SheetWorkers it is an interraction.  I will examine my code and the original code and see what is different, when I find it I'll have the solution.  My guess is its that it has something to do with the radio button/checkbox tabs to "sort" the buffs based on type and if they are enabled or disabled. Since thats that is the only code I don't know how it functions it stands to reason, something nasty could be hiding within it.  Thank you for helping me narrow down my search.
1510768034

Edited 1510768085
chris b.
Pro
Sheet Author
API Scripter
if it's in the "autoCalcFormula" and it goes away when you comment html, it's coming from Roll20 code. I'd look in the html for a field that has "disabled" in it, that might be one that is causing the problem. Look at the value="@{formula}+@{somethingelse}" and maybe it's referencing something that does not exist in your sheet, or maybe just some bad text is entered into whatever field it is reading on that particular sheet
Ack sorry, been so busy, forgot about this thread..  Unfortunately, I made an error and it didnt go away when I commented it out.  I ended up rolling back my sheet to the previous day's work cut and paste the code back in and it vanished.  I have no idea what caused it, but I didn't really think it would be worth the however long it would take to go through every line of code, just for a learning experience. If it comes up again I will make a more careful not of what I do at each step.  I got greedy and did too much between each testing and thats kinda what messed me up.  Sorry I didn't state that here before.  As I said, last few days been busy. Trying to get those sorting tabs to work (and gave up in disgust).  Working on my two current games getting ready for the holidays and slowly planning out how I'm going to get this stupid buff thing to work.  Apart from the buff types and stacking vs non it would be fairly easy I imagine.  Have some ideas to use arrays for each Buff with each buff type being an element to that array and then totalling that array before passing it on to the character sheet, but its not past the psuedo-code stage of planning.
1510783458

Edited 1510783881
chris b.
Pro
Sheet Author
API Scripter
the buff stacking was a nightmare. but that's basically what I did. An array where each buff has a bonus (AC, reflex saves) and the type (enhancement, ..) , and the value. then you have to grab all the related bonuses and types, and for each bonus grab the max by type (unless it's a stacking type&nbsp; in which case you add)&nbsp; Also you have to add penalties separately and only add them in at the end since they always stack. only after doing that can you sum up all the types to arrive at the final value for that bonus. (for ease i just made "penalty" a bonus type and treated it like stacking just like dodge) And of course because you could have something like "bonus to all attacks" and "bonus to melee attacks" , if you want that, you have to subtract the "all attacks" from the "melee attacks", but do it by TYPE before you sum it up for melee attacks. so that's another pass through&nbsp; I don't know if my terminology is exactly how Paizo uses it, my version is in PFBuffs.js below under the "src" directory , i cheated a little by making Armor and Shield and Natural their own bonuses instead of * to AC (since otherwise you have "enhancement bonus to shield bonus to AC" and I didn't want to do 3 levels like that) plus I don't enforce only valid types so people can put what they want based on house rules or whatever. This did cause a few problems with Mage armor and Magic Vestment so i had to put in exceptions for those. And of course all the stupid fields that already existed all over the sheet. It would be easiest to get rid of all those and just have the buff grid, but that is not intuitive for players to fill out. here, in src directory, PFBuffs.js <a href="https://github.com/Roll20-Pathfinder-Character-Sheet/Roll20-Pathfinder-Character-Sheet" rel="nofollow">https://github.com/Roll20-Pathfinder-Character-Sheet/Roll20-Pathfinder-Character-Sheet</a>
1510784262

Edited 1510785402
Toby
Pro
wait... you wrote that code? EeeeeE! My html code is identical to your code (except for the destination for the final buff.. How hard would it be to bring that into my sheet. Is it dependent on other parts of your sheet to function or can it stand alone. I mean I dont use repeating equipment to handle armor like you do. and other things like that. Edit: Replying to your Edit I built my shield from the start hoping r20 would eventually allow repeating section values to be used outside.&nbsp; When it finally could be, I couldnt do anything with it because the means of doing so wasn't as simple as the normal autocalcs..&nbsp; So, I have all sorts of values across the sheet. using the syntax attr_cond-ATTRIBUTE_NAME-2 .&nbsp; attr_cond-ATTRIBUTE_NAME-1 I use for preset togglable conditions such as dazed or invisible and so on.&nbsp; So, I can just add everything up and shove it straight from script without going worrying about the armor or ability score or saves' scripts.&nbsp; I never even considered AC problems.&nbsp; Also, wouldn't the attack (ranged) or attack (melee) bonuses stack with any given to attack (all)?
1510785070

Edited 1510785097
chris b.
Pro
Sheet Author
API Scripter
well the buffToTot maps the names of each bonus to the total field that contains the final values, so that's where the middle part of the "total fields" names go . if your total fields have different names you'd want to adjust these and the next one:&nbsp; in buffTotFields it&nbsp;adds "_exists" and "-total" to each of those names, and "-penalty" to bonuses to ability scores since they are tracked seperately. so buffTotFields is where the final total fields really go. you'd have to check for "-total" and "_exists" throughout the file and change those if necessary. _exists is just a flag to make it appear or not on the sheet in the "status panel" and " otherCharBonuses " is a map of bonuses to other fields on the sheet, so you can remove any that don't apply if your sheet doesn't have those fields. the events ={ lots of stuff } is where it calls all the other portions of the sheet to re-calculate values based on the buff once it's set. That is called at the end so if you want to remove that just search for "event" and delete those calls. it doesn't really look at the equipment list, it looks at the armor and shield locations, which is in the otherCharBonuses and charHelperFields you wouldn't need&nbsp; mergeOldIntoNewBuffs at all or the "common buffs" which is the dropdown on our sheet that lets people easily add in mage armor, etc.&nbsp; reEvaluateCustomMacros is what calculates the value of each macro field..&nbsp; Even with all that you still need underscore.js , which you can get on the net, and most of the above won't work without the other 2 files PFSWUtils.js (lots of utils) and ExExp.js (which evaluates macro equations)
Again, our messages are getting crossed as we type. LOL I've tried to use SWUtils before and I could never to get it work. I thought underscore was part of r20 itself. I'd love to include the "Common Buffs" if I could. I kinda abandoned the idea because I didn't think I'd be able to code it. But if I can import this code into this then I'd gladly import it. So let me see if I have this straight i need: PFSWUtils.js ExExp.js Underscore.js and Obviously TAS.js and thats it? Then I need to change the output variables to match my sheet. I dont have the status panel. And I probably wont use one.&nbsp; I am reducing the need to open up the character sheet.&nbsp; Although, the functionality may be useful for some of my roll templates especially my CharInfo and CharStatus.&nbsp; I could do the Status Panel as part of the chat output.
I've added the underscore, its all wierd and on one line, but it seems to work.&nbsp; But when I go to add the other stuff I get an error message: unexpected token import or unexpected token export if I remove the top few lines with the import stuff, the export stuff is all part of functions, and I'm hesitant to remove that because it is part of functions.
1510789996
Jakob
Sheet Author
API Scripter
Toby said: I've added the underscore, its all wierd and on one line, but it seems to work.&nbsp; But when I go to add the other stuff I get an error message: You don't need to add underscore, it's already included with Roll20.
Thats what I thought, but I guess I was too sleepy to understand the message.. and the rest?
I'm looking for some clarification when I try and import that code into my sheet workers I get an unexpected token import error.&nbsp; If I remove the first few lines of each code that deal with the import, I get an unexpected token export error instead is there something I'm doing wrong, should I instead be putting that code in as API (I am hoping not).
1510854432
chris b.
Pro
Sheet Author
API Scripter
yeah anything that says "import xx" take out that line if you're not using it.they are references to other files,&nbsp; they are referenced mostly in the events:{...} object.&nbsp; for unexpected token export, that is the lines "export function ...."&nbsp; that is because it is using "ES6" syntax. That just means those functions are public so other modules can see it. If you are not using ES6 modules you need to change the syntax of those functions. Or if you're using Revealing Module (like how TAS is written) you need to rewrite the function declarations using that. if you're using node they describe how to change it to common.js, but to do Revealing Module just have to rewrite the declarations. It is not hard to do. <a href="https://stackoverflow.com/questions/38296667/getti" rel="nofollow">https://stackoverflow.com/questions/38296667/getti</a>...
1510856213

Edited 1510856668
Toby
Pro
That link doesnt really tell me anything, at least not in a way that I am understanding. Edit:&nbsp; I realize this might be an imposition but is there any way I could ask you to re-write one of those exports in a way that will function and I might be able to take that and go from there? export function handleExpression (msg) { //replace spaces. replace "-" in front with "0-", replace "(-" with "(0-" //also replace leading + with '', and replace (+ with (0+ var chunks = [], asts = [], cmd, state, ast; msg = msg.replace(/\s/g, '').replace(/^-/, '0-').replace(/\(-/g, '(0-').replace(/^\+/, '').replace(/\(\+/g, '(0+'); cmd = msg; state = { 's': cmd }; //TAS.debug(msg); ast = parseExpression(state, null); //TAS.debug(ast); if (typeof (ast) === "string") { write("could not parse" + msg); return ""; } asts.push(ast); state.s = (state.tok) ? (state.tok.text + state.s) : state.s; // ((state.tok || {'text': ""}).text || "") + state.s; chunks.push(state.s); return sendCommand(chunks, asts, [], {}); } Above chosen at random from the ExExp.js
1510868511
chris b.
Pro
Sheet Author
API Scripter
i don't know what you need, are your other modules all Revealing Modules ? (like the pathfinder sheet used to up until maybe 8 months ago) ? i.e. does it look like the TAS.js code? if not,&nbsp;you could try just deleting the word "export"&nbsp; or if that doesn't work, rewrite them to be : handleExpression = function (msg) { &lt;everything inside the same&gt; } that's the only type of change. &nbsp;
Neither I think, all of my code is self-contained, I dont use functions that link to each section of my sheet to each other for the most part.&nbsp; With the exception of some _.bind() functions for the ability scores and repeating skillls. Everything else is, basically&nbsp; take stuff from the sheet, calculate and evaluate and then shove values back to the sheet.&nbsp; Not sure if thats what your asking but I think it is. Anyways, I'll try simply removing the word "export" as you suggested above. Thank you.
I have gotten them all imported and now when the page loads I get the following error: ReferenceError: PFAbilityScores is not defined &nbsp;&nbsp;&nbsp; at eval (eval at messageHandler (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6</a>), &lt;anonymous&gt;:3638:19) &nbsp;&nbsp;&nbsp; at Function.m.map.m.collect (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:2566" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:2566</a>) &nbsp;&nbsp;&nbsp; at m.(anonymous function) [as map] (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:15545" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:15545</a>) &nbsp;&nbsp;&nbsp; at eval (eval at messageHandler (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6</a>), &lt;anonymous&gt;:3637:37) &nbsp;&nbsp;&nbsp; at eval (&lt;anonymous&gt;) &nbsp;&nbsp;&nbsp; at messageHandler (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6</a>) sheetsandboxworker.js?20170926:sourcemap:303 ReferenceError: PFAbilityScores is not defined &nbsp;&nbsp;&nbsp; at eval (eval at messageHandler (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6</a>), &lt;anonymous&gt;:3638:19) &nbsp;&nbsp;&nbsp; at Function.m.map.m.collect (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:2566" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:2566</a>) &nbsp;&nbsp;&nbsp; at m.(anonymous function) [as map] (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:15545" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:5:15545</a>) &nbsp;&nbsp;&nbsp; at eval (eval at messageHandler (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6</a>), &lt;anonymous&gt;:3637:37) &nbsp;&nbsp;&nbsp; at eval (&lt;anonymous&gt;) &nbsp;&nbsp;&nbsp; at messageHandler (<a href="https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6" rel="nofollow">https://app.roll20dev.net/js/d20/sheetsandboxworker.js?20170926:276:6</a>) Looking at the code it seems to have tons of references that orphaned, referencing all of the other *.js modules.&nbsp; This might be a problem since I dont use them and dont wish to use them.&nbsp; Not, knowing what they do and how they interact this could pose a problem.&nbsp; Just wanted to point this out. I suspect even if I cleared this error, I have a feeling I'd have to deal with PFSaves, PFAbilityScores, PFAttacks, PFAttackGrid, PFDefense, PFHealth, PFInitiative, PFEncumbrance, PFSize...&nbsp; I am seeing refenences to all of them.&nbsp; It looks like it might be just to force the sheet to update itself when those sections change, if thats the case I might be able to get around things because all I want and need this script to do is calculate and shove the buffs into the totaled fields, and then I can create an onChange() event for that field and make that part of the of each of the sections of code that need it.&nbsp; If thats not why its referencing the other sections, I'm in for a long winter vacation.. :D