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

Concentration API not working with mod greater 9

It seems like the API crashes whenever a PC has a mod of greater than 9. I get this error when it fails. Could not determine result type of: [{"type":"M","expr":1},{"type":"C","text":"d20cf<-1cs>-1+10"}] undefined
1582568352
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Which Concentration script are you using? There are several. A link to the place where the code is stored would be handy.
<a href="https://github.com/RobinKuiper/Roll20APIScripts/tree/master/Concentration" rel="nofollow">https://github.com/RobinKuiper/Roll20APIScripts/tree/master/Concentration</a> Was using the Roll20 Library one, and then updated to the most recent version posted in the link above.&nbsp;
Hi Gary, I'm using the very same one and I can still add Concentration at 10 and above. What status marker are you using for Concentration?
Using the default Stopwatch marker
Checked to see if any other API might be interfering, but after disabling all of them except concentration. I don't think that is the case. Using standard default Token Markers
Hm, I have no idea then, sorry. Do the problem persist if you create a new game or a copy of the old one?
Problem persists in Copied Game, and in multiple games
1582583079
Victor B.
Pro
Sheet Author
API Scripter
Probably the issue is that you can't have double digit numbers on a icon.&nbsp; Roll20 doesn't allow it.&nbsp; Try adding an icon and entering double digits on it manually.&nbsp; You'll find you can't.&nbsp; So if the script is trying to apply double digits to a status marker, Roll20 won't show the icon.&nbsp;&nbsp;
1582593452

Edited 1582593558
The status icon itself wont have numbers on it. The API just recognizes the icon and assumes that the associated character sheet is concentrating. When the API recognizes that character has taken damage, it automatically rolls a concentration check. I'm getting this error if the associated character has a CON SAVE MOD of &gt;9. Such as posted below. If it's at 9. it works just fine. 10, it'll break it. Below is the exact output of the API Output Console
1582593795
Victor B.
Pro
Sheet Author
API Scripter
Are you using Roll20 Default or custom status markers?
Default
Upon further messing around and looking at how the math works. The error seems to occur when the math starts going negative. Below is line 260 in the API. Keep in mind I'm not an API ninja, but I can fumble my way through some things. sendChat(script_name, '[[1d20cf&lt;'+( DC-con_save_mod-1 )+'cs&gt;'+(DC-con_save_mod-1)+'+'+con_save_mod+']]', results =&gt; { With a CON SAVE MOD of 10+ and taking damage enough that equals in a Concentration Check that has a DC of 10. The math starts creating a number there that creates a negative number. I think. Check the BOLD. Say the PC takes 10 damage, the DC would be 10, but the CON SAVE MOD is 10. the math there would go "1d20cf&lt;'( 10-10-1 )+'cs&gt;'+( 10-10-1 ).... I'm thinking this is where the crash is occurring? Does my logic follow? Upon further messing around, the API still works if the algorithm doesn't create a DC with a higher number, such as taking 60 damage.
1582600467
Victor B.
Pro
Sheet Author
API Scripter
Yes it does.&nbsp; Come up with a fix and post to Roll20.&nbsp; Robin hasn't been seen for a long time
Hmm, just gotta math my way through it. Not my strong suit. but will give it the old college try
1582607075

Edited 1582608125
Hmm, looking past the obvious, I've realized that anytime it makes that negative number, it would be an automatic success.. Perhaps a way to code in a check to see if the CON SAVE MOD is higher than the DC, and skip that piece of math that crashes it and declares the check a success? Would coding something like that be relatively simple? I'm not a coder by nature. Something like "if DC =&lt; Con_Save_Mod, then auto Success"?
1582654413

Edited 1582654434
Victor B.
Pro
Sheet Author
API Scripter
check the damage vs the con modifer.&nbsp; &nbsp;if (damage &lt;= con save mod) {sendchat('success')}else{normal sendchat}
1582673100

Edited 1582673317
At least from what I can glean. It seems the damage taken creates a DC, so I may just stick with that idea for now. Seeing as I'm not very coder friendly &nbsp;experienced. Is there some resources for reading up on how to code these API's?&nbsp;
1582681127
Victor B.
Pro
Sheet Author
API Scripter
google javascript if (for an if statement).&nbsp; Look at existing code.&nbsp; In thinking about your issue, if con save &gt; damage, then there's no concentration roll right?&nbsp; Of can you still fumble and fail?&nbsp;&nbsp;
Well, the damage sets the DC. Damage/2=DC. From looking at the code, that is already implemented. The minimum DC is 10. If the CON SAVE MOD is 10 or higher, there's no way they can fail. So we might as well skip that roll. That is why I thought maybe coding a way to skip the math on line 260 may work. If code is added to check the DC vs the CON SAVE MOD (CON SAVE MOD =&gt; DC) then we could just post a success instead of the API crashing.