Yeah. It's hard to debug something like this from the outside, and frankly, it's more effort than I want to put into it. I have no idea what this script is supposed to do, only that it nebulously crashes at some point. You didn't explicitly say it in this thread, but if it's getting a "possible infinite loop detected" error, it's taking too long to run somewhere. As I mentioned in the other thread, if setting a variable causes something to run for too long, the problem is probably somewhere it branches based on that variable. The eval() function is dangerous because of the potential for injection attacks (something you honestly don't have to worry about on Roll20's API Sandbox, you're the only user), but it also makes debugging difficult as you have even less visibility into the code as it executes than you do on API scripts. But possibly more importantly, it's very slow. It basically has to spin up a mini-sandbox each time you call it, and you're calling it 15 times. Additionally, we don't know what the implementation is like in the Roll20 sandbox, it's entirely possible that any crashes in eval()'d code will just hang, causing the a "possible infinite loop detected" because there isn't a connection between the eval()'s sandbox and the API sandbox. Several of the eval() calls are being executed on obj properties that are not defined anywhere, which means you'd be eval()'ing undefined, which throws a SyntaxError exception. (Those properties are coming out of whatever JSON is in the skillA and skillB, so who knows what it is...) Something else to consider is the attrLookup() and attrNameLookup() functions, both of which I wrote. They are super handy for dealing with repeating group attributes in the API, but they are pretty expensive. Each one does a 2 findObjs() calls and some complicated sorting. They could be optimized with some caching, but avoiding calling them unless necessary would be a good idea. The code you linked has this in it: let leveldiff = InLvB - InLvA;
let ohno = 0;
//leveldiff is busted what
if (leveldiff >= 0){
ohno = (31 + leveldiff)/3;
} else if (leveldiff == -1){
ohno = 10;
} else {
ohno = Math.max((33 + leveldiff)/3, 1);
}
log(ohno)
//EXPAmod = mod
log(Math.floor(ohno))
//EXPAmod = mod;
which I think is the code you're talking about in this thread. Right after, it loops over all the SkillsA and SkillsB arrays and uses them in invoking the Skill() function. The 8th (!!!) parameter to that function is the skill data from the SkillA and SkillB arrays. The Skill() function will call eval() on 2 of that skill object's properties. It then has several places where it will can call skillMain(), which then calls eval() on 8-10 other properties. The only way to track down this bug is to log things like crazy and analyze where it's going.