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

API keeps crashing from using CSA

I'm not sure if this is the right forum to be posting this in but the API in my game keeps crashing when I try to run a macro with ChatSetAttr in it. What's particularly odd is I haven't changed the macro since it was last working so I have no idea why it's started crashing. The error message it puts out on crashing is: Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: TypeError: Cannot read property 'current' of undefined TypeError: Cannot read property 'current' of undefined at Object.entries.reduce (apiscript.js:837:65) at Array.reduce (native) at setCharAttributes (apiscript.js:833:52) at dWork (apiscript.js:763:6) at delayedGetAndSetAttributes (apiscript.js:773:4) at handleInput (apiscript.js:1292:7) at eval (eval at (/home/node/d20-api-server/api.js:146:1), :65:16) at Object.publish (eval at (/home/node/d20-api-server/api.js:146:1), :70:8) at /home/node/d20-api-server/api.js:1510:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 I think the only other API the game is running is the OGL companion script but I'm pretty sure that's not used in the macro. Thanks for any help anyone can provide.
1511813062
The Aaron
Pro
API Scripter
Hmm.  I can tell you the issue is happening at line 284 of ChatSetAttr, in the setCharAttributes() function.  When it gets to that point, it tries to access the attribute in the charFeedback object, but it hasn't been set.  This seems to indicate a mismatch between the setting argument (which is used for looking for what to provide output feedback) and the attrs argument (which is used to make changes and load the charFeedback object).  setting is passed into delayedGetAndSetAttributes(), but attrs is generated in that function by calling getCharAttributes() with settings among it's arguments. I'd have to get a reproduction case and drop a bunch of debug statements in to figure it out.  Hopefully Jakob will drop by shortly and point out the issue.
1511813078
The Aaron
Pro
API Scripter
You might want to post in the ChatSetAttr thread.
1511814337
Jakob
Sheet Author
API Scripter
Could you tell me the command you're running? You're probably using --fb-content, I assume? It looks like The Aarons's analysis is correct (of course) and charFeedback[attrName] is undefined. I could see this happening with --nocreate, maybe ... the keys of attrs should always be a subset of those of setting, perhaps there's a way they are a true subset, or perhaps it's just a lower case / upper case thing. Either way, the command you are using would be helpful to know.
The Aaron said: You might want to post in the ChatSetAttr thread. I thought about doing that but for some reason I thought the thread was closed to replying. Jakob said: Could you tell me the command you're running? You're probably using --fb-content, I assume? It looks like The Aarons's analysis is correct (of course) and charFeedback[attrName] is undefined. I could see this happening with --nocreate, maybe ... the keys of attrs should always be a subset of those of setting, perhaps there's a way they are a true subset, or perhaps it's just a lower case / upper case thing. Either way, the command you are using would be helpful to know. I've got 4 uses of CSA running in the same macro 2 setattrs a delattr and then a final big setattr. The first 3 all use --silent, all 3 setattr use --evaluate and the last setattr was using --fb-header and --fb-content.  After removing the --fb-header and --fb-content from the last one, after you saying that may be the cause, the macro works without crashing the API. I would like to be able to use --fb-content though if possible though.
1511816842
Jakob
Sheet Author
API Scripter
Can you please give me the full command that's using fb-content? I need to know what the input is to debug it...
I was hoping the whole thing wasn't needed because it's so large haha !setattr {{--fb-header --fb-content _CUR0_ _CUR30_ _CUR31_ --evaluate --name @{character_name}  --name|if ("%mind%"=="nulara") {"Nulara Calabra"} else {"Esvele Calabra"} --race|if ("%mind%"=="nulara") {"Fire Genasi"} else {"Water Genasi"} --intelligence|if ("%mind%"=="nulara" ? !(%i%>%j%) : %i%>%j%) {%j%} else {%i%} --wisdom|if ("%mind%"=="nulara" ? !(%i%>%j%) : %i%>%j%) {%i%} else {%j%} --arcana_prof|if ("%mind%"=="nulara") {"%arcanapb%"} else {0} --insight_prof|if ("%mind%"=="nulara") {0} else {"%insightpb%"} --intimidation_prof|if ("%mind%"=="nulara") {"%intimidationpb%"} else {0} --persuasion_prof|if ("%mind%"=="nulara") {0} else {"%persuasionpb%"} --repeating_traits_$1_name|if ("%mind%"=="nulara") {"Darkvision"} else {"Amphibious"} --repeating_traits_$1_source_type|if ("%mind%"=="nulara") {"Fire Genasi"} else {"Water Genasi"} --repeating_traits_$1_description|if ("%mind%"=="nulara") {"60 ft darkvision. Shades of red not grey."} else {"You can breathe air and water."} --repeating_traits_$2_name|if ("%mind%"=="nulara") {"Fire Resistance"} else {"Acid Resistance"} --repeating_traits_$2_source_type|if ("%mind%"=="nulara") {"Fire Genasi"} else {"Water Genasi"} --repeating_traits_$2_description|if ("%mind%"=="nulara") {"You have resistance to fire damage."} else {"You have resistance to acid damage."} --repeating_traits_$3_name|if ("%mind%"=="nulara") {"Reach to the Blaze"} else {"Call to the Wave"} --repeating_traits_$3_source_type|if ("%mind%"=="nulara") {"Fire Genasi"} else {"Water Genasi"} --repeating_traits_$3_description|if ("%mind%"=="nulara") {"You know the produce flame cantrip. Once you reach 3rd level, you can cast the burning hands spell once with this trait as a 1st-level spell, and you regain the ability to cast it this way when you finish a long rest. Constitution is your spellcasting ability for these spells."} else {"You know the shape water cantrip. When you reach 3rd level, you can cast the create or destroy water spell as a 2nd-level spell once with this trait, and you regain the ability to cast it this way when you finish a long rest. Constitution is your spellcasting ability for these spells."} --repeating_traits_$4_name|if ("%mind%"=="nulara") {"Ignite"} else {"Swim"} --repeating_traits_$4_source|if ("%mind%"=="nulara") {"Class"} else {"Racial"} --repeating_traits_$4_source_type|if ("%mind%"=="nulara") {"Phoenix Sorcerer 1st Level"} else {"Water Genasi"} --repeating_traits_$4_description|if ("%mind%"=="nulara") {"As an action, you can magically ignite a flammable object you touch with your hand—an object such as a torch, a piece of tinder, or the hem of drapes."} else {"You have a swimming speed of 30 feet."} --repeating_traits_$5_name|if ("%mind%"=="nulara") {"Mantle of Flame"} else {"Curse of the Sea"} --repeating_traits_$5_source_type|if ("%mind%"=="nulara") {"Phoenix Sorcerer 1st Level"} else {"Sea Sorcerer 1st Level"} --repeating_traits_$5_description|("%mind%"=="nulara") ? `@{mantle}`:`@{curse}` --repeating_spell-cantrip_$2_spelloutput|if ("%mind%"=="nulara") {"SPELLCARD"} else {"ATTACK"} --repeating_spell-cantrip_$3_spelloutput|if ("%mind%"=="nulara") {"SPELLCARD"} else {"ATTACK"} --repeating_spell-cantrip_$4_spelloutput|if ("%mind%"=="nulara") {"SPELLCARD"} else {"ATTACK"} --repeating_spell-cantrip_$5_spelloutput|if ("%mind%"=="nulara") {"SPELLCARD"} else {"ATTACK"} --repeating_spell-cantrip_$6_spelloutput|if ("%mind%"=="nulara") {"ATTACK"} else {"SPELLCARD"} --repeating_spell-cantrip_$9_spelloutput|if ("%mind%"=="nulara") {"ATTACK"} else {"SPELLCARD"} --repeating_spell-1_$1_spelloutput|if ("%mind%"=="nulara") {"ATTACK"} else {"SPELLCARD"} --repeating_spell-1_$2_spelloutput|if ("%mind%"=="nulara") {"SPELLCARD"} else {"ATTACK"} --eyes|if ("%mind%"=="nulara") {"Fire Red"} else {"Pale Blue/White"} --skin|if ("%mind%"=="nulara") {"Deep Red"} else {"Light Blue"} --hair|if ("%mind%"=="nulara") {"Fire Orange/Red"} else {"Blue"} }} That's what I'm using now except I have removed the --fb-header --fb-content parts like I said.
1511824132

Edited 1511824145
Jakob
Sheet Author
API Scripter
Okay, so what seems to be happening is that when one of the referenced repeating rows do not exist, they will not be created, which makes it so that something is undefined which shouldn't be (but it only comes up with the way --fb-content is written). I'll change it in the script. Regardless, is it intended that all those repeating trait commands wouldn't do anything unless they exist already?
1511829809

Edited 1511831930
Jakob said: I'll change it in the script. So can I use --fb-content without the API crashing anymore? Regardless, is it intended that all those repeating trait commands wouldn't do anything unless they exist already? It is not intended that way but they should already exist anyway. Also, can you thing of any reason why the repeating_spell-cantrip_$9_spelloutput isn't working as it does for all the other rows? Even changing it to $8 for the previous row works as intended but for some reason it doesn't work on $9. EDIT: fixed this issue idek how
1511868258

Edited 1511872172
Jakob
Sheet Author
API Scripter
So can I use --fb-content without the API crashing anymore? Once I update the script, yes. EDIT:&nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/pull/549" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/pull/549</a> .
Jakob said: So can I use --fb-content without the API crashing anymore? Once I update the script, yes. EDIT:&nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/pull/549" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/pull/549</a> . Thanks muchly :)
1511961371
Jakob
Sheet Author
API Scripter
The bugfix (version 1.7.1) is live now.