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 .
×

[Help] API crashing when trying to sendChat an ability in 5e OGL sheet

1537901020

Edited 1537901660
TMW
Pro
I'm trying to have my script send an attack from a character sheet to chat but it's crashing and I'm not sure why. Here is the code with all unrelated parts removed: var mimicID = "-LNGjj6sLmXPo6vTrHwa" on("chat:message", function(msg) {     var charid = "character|" + mimicID;     sendChat(charid, "%{Mimic.|longbow}");    }); I first made the attack in the Attacks & Spellcasting section of the Mimic. sheet. Clicking up arrow results in: @{Mimic.|wtype}&{template:atkdmg} {{mod=+5}} {{rname=Longbow}} {{r1=[[@{Mimic.|d20}cs>20 + 5[MOD]]]}} @{Mimic.|rtype}cs>20 + 5[MOD]]]}} {{attack=1}} {{range=150/600}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d8 + 3[MOD]]]}} {{dmg1type=piercing }} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d8[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=}}   {{spelllevel=}} {{innate=}} {{globalattack=@{Mimic.|global_attack_mod}}} {{globaldamage=[[0]]}} {{globaldamagecrit=[[0]]}} {{globaldamagetype=@{Mimic.|global_damage_mod_type}}} ammo= @{Mimic.|charname_output} I took that and created an ability called "longbow" and pasted in the above. If I type %{Mimic.|longbow} manually into chat it works fine. But if I try to do sendChat with that text I get the error: For reference, the error message generated was: Could not determine result type of: [{"type":"M","expr":0},{"type":"L","text":"CRIT"}] undefined I'm not really sure what the error is saying, I don't see that text anywhere in the attack string. Any help would be appreciated. EDIT: The sender (first arg of sendChat) does not affect the error, nor does escaping any of the message characters. I noticed someone had a similar error when trying to do an attack without dice rolls which leads me to believe I have some configuration error in my attack but I haven't found a combination that works.
1537902264
Jakob
Sheet Author
API Scripter
That's probably a symptom of the broken API parser for inline rolls. Try removing the "{{crit2=[[0[CRIT]]]}}" part (it doesn't do anything anyway).
Removing that section fixed it, thank you! Turns out it did involve having a section that didn't roll a dice.
1537902711
Jakob
Sheet Author
API Scripter
TMW said: Removing that section fixed it, thank you! Turns out it did involve having a section that didn't roll a dice. I think it's the combination of having roll tags (like [CRIT]) and not having dice which breaks the API parser... it's really dumb that it isn't the same as the one for regular chat messages.