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

Wanting to know the limitation of sendChat(SpeakingAs,Message); function

1591199742

Edited 1591199798
So I have several Token Macro's on characters that reference other macros, that have character sheet rolls placed in them (press character roll, press up in chat window, cut and paste into macro's, works great). Anyways, to the point of this topic. I also have many API's that grabs data, manipulates it and send back to the Character sheet (with API calls such as ChatSetAttr).  I tried to create a very long list of switch/case select options that would automaking send multiple sendChat(SpeakingAs,API/Macro) Below is one such example: case 1: switch(args[3]){ case "FlurryOfBlows": sendChat(SpeakingAs,"After attacking with my Action, I channel my Ki and make two Unarmed Strikes!"); sendChat(SpeakingAs,"%{"+CharacterName+"|MA:UnarmedStrikes}"); sendChat(SpeakingAs,"%{"+CharacterName+"|MA:UnarmedStrikes}"); break; As seen above this takes in nested switch/case scenarios (outer case is how Class Resources you want to use (Ki in this case) which is provided by the API script parameters (Call is !UsaAResource <character token Id> <character ID> <numbers of resource used> <String that corresponds to an ability(use a dropdown Query to ensure proper names)>) My problem so far is that it will get to this part of my API but then break on the line that's bolded above with the following error code. And I'm not sure why it is doing that. I know this is where it fails because I see the sendChat right above it but then my token Macro isn't rolls. Just curious if that |\t things its talking about has anything to do with a work around. I could post my entire code, but pretty sure this is specific to the line I provided (basically I tested every line up to this point to make sure it worked before adding new code). Which is why if anyone is very familiar with what is going on behind sendChat, I would love to pick your brain :) I'm hoping there is some type of html replacement that could fix this cause what I have going would be very robust (minimal changes needed, completely automated ability usages with updates to resources used for it). Let me know your thought and if you still want to see the code I could post here (don't have gist unfortunately)
1591200296
The Aaron
Roll20 Production Team
API Scripter
I don't believe the API can call Character Abilities.  Even if it can, there are usually problems with the contents of such macros.  I have a script called OnMyTurn that handles this by directly expanding the contents of an Ability and issuing the commands from it directly.
Okay Long winded post here, going to give my example of what it is that I am doing.... I don't mind hard coding in some of this if it makes it possible just don't want to get hung up on some OTHER thing that might stop this from working.  Side note I am using the Contributed Community Character sheet for 5e. So I have 3 specific Token Macros: MonkAbilities, ConfirmMonkAbilities, UpdateKi I also have many macros that make attacking with weapons easier so you don't have to go into the character sheet and press roll everytime: "MA:UnarmedStrikes" (essentially all the template attack Hoopla plus maybe extra stuff to give the player more information) refer to these as minor token macro's (as their entire content could theoretically be copy and pasted? Maybe? Below is my Big API function that handles dishing out stuff via sendChat commands: // Syntax for this API is ToddUseFirstResourcee <Selected|token_id> <Selected|character_id> <Amount of resource spent> <String for ability used> on("ready",function(){ on("chat:message",function(msg){ if(msg.type=="api" && msg.content.indexOf("!ToddUseFirstResource")==0 ){ var selected = msg.selected; if (selected===undefined){ sendChat("API","Please select a character."); return; } var args = msg.content.split(" "); var command = args.shift().substring(1); if (command == 'ToddUseFirstResource'){ if (args.length < 4) { sendChat('SYSTEM', 'You must provide a selected token id, character id, the Number of Resources Used and abilities used'); return; } } // 1st Parameter should be the Token's Id var Selected_Tok_Id = args[0]; var Selected_Char_Id = args[1]; var Selected_ResourceNumberSpent = args[2]; var Selected_Name_of_Monk_Ki_Ability = args[3]; Selected_ResourceNumberSpent = parseInt(Selected_ResourceNumberSpent,10); var Selected_Token = getObj('graphic', Selected_Tok_Id); var Selected_Character = getObj('character',Selected_Char_Id); if (!Selected_Tok_Id) { sendChat('SYSTEM', 'Selected token id not provided.'); return; } if (!Selected_Char_Id) { sendChat('SYSTEM', 'Selected character id not provided.'); return; } if (Selected_ResourceNumberSpent < 0) { if(typeof Selected_ResourceNumberSpent != 'number'){ sendChat('SYSTEM','Please provide a number for amount of resource spent!'); return; } sendChat('SYSTEM', 'Resource Number Spent not provided.'); return; } if(!Selected_Name_of_Monk_Ki_Ability){ sendChat('SYSTEM', "You did not specify a Monk Ki Ability that I was using!") } //Preparing to get speakingas for sendChat var SpeakingAs = getObj('character', Selected_Token.get('represents')); var CharacterName = Selected_Character.get('name'); if(!SpeakingAs){ SpeakingAs = Selected_Token.get('name'); } else { SpeakingAs = 'character|' + SpeakingAs.id; } var CurrentSum = getAttrByName(Selected_Char_Id, "repeating_classresources_$0_ClassResourceTotal", "current"); var MaxSum = getAttrByName(Selected_Char_Id, "repeating_classresources_$0_ClassResourceTotal", "max"); var AttributeName = getAttrByName(Selected_Char_Id,"repeating_classresources_$0_ClassResourceName"); // Make sure attr are integers CurrentSum = parseInt(CurrentSum,10); MaxSum = parseInt(MaxSum,10); // Use Resource CurrentSum = CurrentSum - Selected_ResourceNumberSpent; //confirm Resource Is available to use. if (CurrentSum < 0){ CurrentSum = CurrentSum + Selected_ResourceNumberSpent; sendChat(SpeakingAs,"It appears that I have tried to use "+AttributeName+" Resources that was not available to me!"); return; } else { switch(parseInt(args[2],10)){ case 0: switch(args[3]){ case "MartialArts": sendChat(SpeakingAs,"After attacking with my Action, I quickly make an Unarmed Strike!"); sendChat(SpeakingAs,"%{"+CharacterName+"|MA:UnarmedStrikes}"); break; case "MinorIllusion": sendChat(SpeakingAs,"%{"+CharacterName+"|repeating_spellbookCANTRIP_$0_spellcast}"); break; case "DeflectMissilesCatch": sendChat(SpeakingAs,"Subtract [[1d10+[[@{"+CharacterName+"|monk_level}]]+[[@{"+CharacterName+"|dexterity_mod}]]]] from a ranged attack that hit me!" ) default: sendChat(SpeakingAs,"I did not specify a proper 0 Ki cost ability"); return;; } sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-0 ]] "); break; case 1: switch(args[3]){ case "FlurryOfBlows": sendChat(SpeakingAs,"After attacking with my Action, I channel my Ki and make two Unarmed Strikes!"); sendChat(SpeakingAs,"%{"+CharacterName+"|MA:UnarmedStrikes}"); sendChat(SpeakingAs,"%{"+CharacterName+"|MA:UnarmedStrikes}"); break; case "PatientDefense": sendChat(SpeakingAs, "Attackers have Disadvantage on attack rolls against me until the beginning of my next turn!"); break; case "StepOfTheWindDisengage": sendChat(SpeakingAs, "I do not provoke Attack of Opportunity from those I am currently within my enemies threat range!"); break; case "StepOfTheWindDash": sendChat(SpeakingAs,"My Movement Speed is increased by [[@{"+CharacterName+"|speed}]] until the beginning of my next turn!"); break; case "DistantEye": sendChat(SpeakingAs,"My Range Attacks Do not suffer from Disadvantage for LongRange"); sendChat(SpeakingAs,"%{"+CharacterName+"|RA:Javelin}"); break; case "DeflectMissilesAttack": sendChat(SpeakingAs,"%{"+CharacterName+"|RA:DeflectMissiles}"); break; case "StunningStrike": sendChat(SpeakingAs,"%{"+CharacterName+"|StunningStrike}"); break; default: sendChat(SpeakingAs,"I did not specify a proper 1 Ki cost ability!"); return; } sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-1 ]] "); break; case 2: switch(args[3]){ case "Darkness": sendChat(SpeakingAs,"%{"+CharacterName+"|repeating_spellbookLEVEL2_$0_spellcast}"); break; case "Darkvision": sendChat(SpeakingAs,"%{"+CharacterName+"|repeating_spellbookLEVEL2_$1_spellcast}"); break; case "Silence": sendChat(SpeakingAs,"%{"+CharacterName+"|repeating_spellbookLEVEL2_$2_spellcast}"); break; case "PassWithoutATrace": sendChat(SpeakingAs,"%{"+CharacterName+"|repeating_spellbookLEVEL2_$3_spellcast}"); break; case "QuickenedHealing": sendChat(SpeakingAs,CharacterName+" heals self for [[1d6]] hit points using Quicken Healing!"); break; default: sendChat(SpeakingAs,"I did not specify a proper 2 Ki cost ability"); return; } sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-2 ]] "); break; case 3: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-3 ]] "); break; case 4: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-4 ]] "); break; case 5: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-5 ]] "); break; case 6: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-6 ]] "); break; case 7: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-7 ]] "); break; case 8: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-8 ]] "); break; case 9: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-9 ]] "); break; case 10: sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-10 ]] "); break; default: sendChat(SpeakingAs,"Number of Resources Spent is either less than 0 or more than 10, please provide a number between [0 and 10]"); break; } // end of Switch Case } // end of If/Else about CurrentSum // If command == UseFirstResource } // If statement from the !UseFirstResource and Api is msg.type }); }); Below is my 3 Helper token macros for the player characters: MonkAbilities: (Sung Fe is the character name that these macro comes from, I require players to have their character selected to get them used to doing that, as many things require that anyway), I pass this information along to and sendChat's that require it !ToddUseFirstResource @{selected|token_id} @{selected|character_id} %{Sung Fe|UpdateKi} %{Sung Fe|ConfirmMonkAbilities} ConfirmMonkAbilities: Used to create parameter for the "!ToddUseFirstResource" API's 4th argument (args[3]) ?{Confirm which Monk Abiilty you are Using|Martial Arts - Bonus Action and 0 Ki,MartialsArts|Flurry of Blows - Bonus Action and 1 Ki,FlurryOfBlows|Patient Defense - 1 Bonus Action and 1 Ki,PatientDefense| Step of the Wind-Disengage - Bonus Action and 1 Ki,StepOfTheWindDisengage| Step of the Wind-Dash - Bonus Action and 1 Ki,StepOfTheWindDash|Distant Eye - Free action as part of a ranged attack and 1 Ki,DistantEye|Quickened Healing - Action and 2 Ki points,QuickenedHealing|Deflect Missile- Catch - Reaction and no Ki,DeflectMissilesCatch| Deflect Missile- Attack- Same Reaction and 1 Ki,DeflectMissilesAttack|Stunning Strike - Free action as part of a melee weapon attack and 1 Ki,StunningStrike|Darkness- Action and 2 Ki,Darkness|Darkvision- Action and 2 Ki,Darkvision|Pass without a Trace - Action and 2 Ki,PassWithoutATrace|Silence - Action and 2 Ki,Silence| Minor Illusion - Action and 0 Ki,MinorIllusion} UpdateKi: ( I know it's not relevant to update Ki 0 stuff, but wanted to keep consistent with players mindset that these abilities do exist and are available to them. Monk got lots of stuff going on and I find my player being overwhelmed with choices, this give them list and context for what they are able to achieve in a given round of combat. Used to create parameter for "!ToddUseFirstResource" API's 3rd argument (args[2]) ?{View All Monk Options you have available|Martial Arts - Bonus Action and 0 Ki,0|Flurry of Blows - Bonus Action and 1 Ki,1|Patient Defense - 1 Bonus Action and 1 Ki,1| Step of the Wind-Disengage - Bonus Action and 1 Ki,1| Step of the Wind-Dash - Bonus Action and 1 Ki,1|Distant Eye - Free action as part of a ranged attack and 1 Ki,1|Quickened Healing - Action and 2 Ki points,2|Deflect Missile- Catch - Reaction and no Ki,0| Deflect Missile- Attack- Same Reaction and 1 Ki,1|Stunning Strike - Free action as part of a melee weapon attack and 1 Ki,1|Darkness- Action and 2 Ki,2|Darkvision- Action and 2 Ki,2|Pass without a Trace - Action and 2 Ki,2|Silence - Action and 2 Ki,2| Minor Illusion - Action and 0 Ki,0} Kind of wouldn't even know where to begin allowing the player (a prompt) to be passed in at first. Most of this is behind the scenes, the player character only see the UpdateKi and ConfirmMonkAbilities content (other than hopefully the attack rolls or spells casts with this. If you have any suggestion I am all ears. Again this is why I wanted to know what limitation to sendChat(SpeakingAs,Message); I read the information on the function but as someone who isn't fluent in javascript or HTML (I understand logic and basic coding guidelines however, my computer literacy is mostly for reading, and not as much for writing specific codes, EC engineer). I can get so hung up on a comp language syntax :( I get the sneaky suspicion that its not actually sending it to the game (at least not without some type of Parsing first) So If I need to have a whole bunch of &#44 &#124 or whatever all those htmls codes are to get it to work I might be willing to do so because it being uglier for me to make it cleaning for them is worth it to me. I was told that an API can call another API, so maybe just copying everything from macro's into API's would work, but still comes down to how I can get the character to press a button, bring up a drop down, brings up another almost identical drop down. and then some type of actions/rolls happen related to that choice is what I'm ultimately trying to achieve. Thank you for your time :)
Crap I logged out of my game and logged back in and those attacked showed up but now my game is busted. the character sheet doesn't roll anything anymore when i press the buttons :(
1591212955
The Aaron
Roll20 Production Team
API Scripter
I'm going to have to dig into this when I'm not working... that's a lot to try and grok...
1591213000
GiGs
Pro
Sheet Author
API Scripter
when nothing is responding in chat, the most common culprit is a corrupt chat archive. Try this: exit the campaign, go to the launch game page, click the settings button, select Delete Chat Archive (actual text might be different), and confirm it. then return to your game and see if things are working again.
I got my Chat window to work again by deleting the archive as you mentioned... I didn't think my API's were that busted :(
1591280642
GiGs
Pro
Sheet Author
API Scripter
Great! It doesnt happen often, but when it does, it's so frustrating, especially when it takes you a while to figure out its not just the API you're working on that is broken.
Also someones going to have to explain to me why MartialArts doesn't work but MinorIllusion does. I know one is referencing a token macro while the other is referencing a character sheet command but the format is exactly the same being "%{charactername|Ability}" while the other is "%{charactername|attribute} (I'm not even sure if the 2nd one is an attribute as I can't find it under the charactersheet information, saw someone use another sheet to cast spells this way and just tweaked it to cast spells with my sheet... else { switch(parseInt(args[2],10)){ case 0: switch(args[3]){ case "MartialArts": sendChat(SpeakingAs,"After attacking with my Action, I quickly make an Unarmed Strike!"); sendChat(SpeakingAs,"%{"+CharacterName+"|UnarmedStrikes}"); break; case "MinorIllusion": sendChat(SpeakingAs,"%{"+CharacterName+"|repeating_spellbookCANTRIP_$0_spellcast}"); break; case "DeflectMissilesCatch": sendChat(SpeakingAs,"Subtract [[1d10+[[@{"+CharacterName+"|monk_level}]]+[[@{"+CharacterName+"|dexterity_mod}]]]] from a ranged attack that hit me!" ) default: sendChat(SpeakingAs,"I did not specify a proper 0 Ki cost ability"); return;; } sendChat(SpeakingAs,"!setattr --silent --charid "+args[1]+" --repeating_classresources_$0_ClassResourceTotal|[[@{"+CharacterName+"|repeating_classresources_$0_ClassResourceTotal}-0 ]] "); break; If anyone knows how to access the  "Classactioncast" variable or "WeaponMelee2cast" variable or where to find them I would be very greatful. I tried @{Sung Fe|ro_melee2} @{Sung Fe|classactionmeleeweapon} command but i get the same complaint about it not liking the vertical pipe character (tried using |\t as it said it was expecting but then I got anothe error saying it could not find substring of undefined. assuming the \t command does something to strings to break them up? Anyway's it actually works (surprisingly) for the MinorIllusion section above, which is frustrating cause it means sendChat can do it, but something is parsing it different on the game side. I even tried 
&#37{charactername|UnarmedStrikes} (simplified my token macros so they didn't include any special characters just in case) Just seems inconsistent is all. Still puzzled.
1591289135
GiGs
Pro
Sheet Author
API Scripter
If its an attribute, you dont use % to call it, you use @. It sounds like you have a problem identifying the attribute and ability names. You need to find out what they actually are before you can call them in a script. There is no inconsistency in how roll20 handles them. Look at the sheet's html to find the attribute and ability names.
1591290907

Edited 1591290952
They are roll commands for the sheet and correspond to a button. When I inspect the character sheet over the "Spell Cast" button one of the fields is name = "roll_SpellCast". My character sheet says I can do things with the repeating sections like repeating_spellbookCANTRIP_$0_spellattack or repeating_spellbookCANTRIP_$0_spelleffect So I just tried repeating_spellbookCANTRIP_$0_spellcast and it worked.  I then tried to duplicate this logic with the weapon attack rolls (they are not repeating sections in my character sheet) but it too has a field {{name = "roll_MeleeAttack2"}}  So then I tried %{charactername|MeleeAttack2} in the API and still didn't work. I tried in normal chat window of the game and it does work.  I know I must be missing something (I tried to do %{charactername|classactionmeleeweapon_MeleeAttack2} ) or the first thing that i append the "_MeleeAttack2" onto. although doing the above %{charactername|MeleeAttack2} did work in the game chat window. I tried %{charactername|repeating_spellbookCANTRIP_$0_spellcast} in both the API(sending to game by sendChat) and in the chat window and it works in both. I'm just curious of the inconsistency as to why in one it doesn't like the vertical pipe but in the other it seems to be okay with it.
Here are some images to help explains what i am encountering (with the above code listed) Me using chat window to perform attack roll using %{charactername|MeleeAttack2} <a href="https://imgur.com/cGqD6Ot" rel="nofollow">https://imgur.com/cGqD6Ot</a> Me using chat window to perform a spell casting using %{charactername|repeating_spellbookCANTRIP_$0_spellcast} <a href="https://imgur.com/rjtuJeT" rel="nofollow">https://imgur.com/rjtuJeT</a> Me using API to cast a spell (same command) <a href="https://imgur.com/AMSndKa" rel="nofollow">https://imgur.com/AMSndKa</a> Me using API to send the same attack roll above&nbsp; <a href="https://imgur.com/P6exbmR" rel="nofollow">https://imgur.com/P6exbmR</a> Error code in API script related to me sending the same attack roll through sendChat <a href="https://imgur.com/VqpMaVz" rel="nofollow">https://imgur.com/VqpMaVz</a> I am actually just surprised the spellcasting one worked as the other one failed so easily.&nbsp;
1591292982
GiGs
Pro
Sheet Author
API Scripter
J.C said: Me using chat window to perform a spell casting using %{charactername|repeating_spellbookCANTRIP_$0_spellcast} <a href="https://imgur.com/rjtuJeT" rel="nofollow">https://imgur.com/rjtuJeT</a> Me using API to cast a spell (same command) <a href="https://imgur.com/AMSndKa" rel="nofollow">https://imgur.com/AMSndKa</a> Me using API to send the same attack roll above&nbsp; <a href="https://imgur.com/P6exbmR" rel="nofollow">https://imgur.com/P6exbmR</a> Error code in API script related to me sending the same attack roll through sendChat <a href="https://imgur.com/VqpMaVz" rel="nofollow">https://imgur.com/VqpMaVz</a> I am actually just surprised the spellcasting one worked as the other one failed so easily.&nbsp; I see the error code. But I'm not seeing any difference in the outputs of the previous commands. What is not working right?
1591293509

Edited 1591293911
The Attack roll coming from the API should look like the 1st image but it only send my Auxiliary Text in the same section of code.&nbsp; Edit:The section of code is also included in that error code picture under "MartialArts" Edit:While doing this I found a different bug(forgot a break; under DeflectMissilesCatch) that I was able to fix so not a complete loss :) Edit!: Sorry i relooked at the pictures I put in the last post and noticed its not there! I'll update ASAP. EDIT: Nm I looked at the top image of your last post and thought i missed it. its should look like this one: J.C &nbsp;said: Here are some images to help explains what i am encountering (with the above code listed) Me using chat window to perform attack roll using %{charactername|MeleeAttack2} <a href="https://imgur.com/cGqD6Ot" rel="nofollow">https://imgur.com/cGqD6Ot</a>
1591294969

Edited 1591295058
GiGs
Pro
Sheet Author
API Scripter
Which character sheet are you using? You do use % to call roll buttons, so that part of the syntax is right. So then I tried %{charactername|MeleeAttack2} in the API and still didn't work. I tried in normal chat window of the game and it does work.&nbsp; If this works in normal chat, then the problem is not the name. It's either something about the way the name is handled in the script, or the contents of that roll. Try html escaping the % at the start of the command, like so sendChat(SpeakingAs," &amp;#37; {"+CharacterName+"|UnarmedStrikes}"); You said earlier you tried &amp;#13;&amp;#37, but that is only for Buttons printed to chat. Here, its just the&nbsp; &amp;#37; &nbsp;part. Once you've tested that to see if it works, I'd combine the two sendChats here into one: sendChat(SpeakingAs,'After&nbsp;attacking&nbsp;with&nbsp;my&nbsp;Action,&nbsp;I&nbsp;quickly&nbsp;make&nbsp;an&nbsp;Unarmed&nbsp;Strike!'); sendChat(SpeakingAs,'%{'+CharacterName+'|MA:UnarmedStrikes}'); Combining them into one is the only way to be sure you get the output in the order you want it. This should work: sendChat(SpeakingAs,`After&nbsp;attacking&nbsp;with&nbsp;my&nbsp;Action,&nbsp;I&nbsp;quickly&nbsp;make&nbsp;an&nbsp;Unarmed&nbsp;Strike! &amp;#37; {${CharacterName}|MA:UnarmedStrikes}`); Note the ` at the beginning and end is a backtick, not a single quote. In your script you have a syntax error at this section (I dont think this is causing your issue but it needs cleaning up anyway): case&nbsp;'DeflectMissilesCatch': &nbsp;&nbsp;&nbsp;&nbsp;sendChat(SpeakingAs,'Subtract&nbsp;[[1d10+[[@{'+CharacterName+'|monk_level}]]+[[@{'+CharacterName+'|dexterity_mod}]]]]&nbsp;from&nbsp;a&nbsp;ranged&nbsp;attack&nbsp;that&nbsp;hit&nbsp;me!'&nbsp;) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sendChat(SpeakingAs,'I&nbsp;did&nbsp;not&nbsp;specify&nbsp;a&nbsp;proper&nbsp;0&nbsp;Ki&nbsp;cost&nbsp;ability'); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;; There's a missing semicolon at the end of the first sendChat line, and a missing break; after it Also a double semi-colon after that return, but that wouldnt cause issues. I'm looking over the script, and I'm confused about the goal of making this script. It seems to me you could do this is a set of macros or abilities, combined with a script like ammo to subtract the resource, and it would likely be a lot easier. What problem is doing it as an API script solving?
1591296213

Edited 1591297062
Mostly the API is protecting the user from not using resources that aren't available to them and letting them know. as if/else cases don't exactly work the way you would want them to with queries (at least when i tried to anyway) I am using the Community Contributed Character Sheet, as it is more appealing visually for me than the other options. Thank you for catching those things. I seen some but not all of those. must have removed something beforehand when trying to do that. I am going to try to suggestion now (before I post this) and hope it works. when i attempt to put in the code you suggested it get angry with me saying unexpected identifier. sendChat(SpeakingAs,`After&nbsp;attacking&nbsp;with&nbsp;my&nbsp;Action,&nbsp;I&nbsp;quickly&nbsp;make&nbsp;an&nbsp;Unarmed&nbsp;Strike! &amp;#37; {${CharacterName}|MA:UnarmedStrikes}`); 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.&nbsp; More info... For reference, the error message generated was:&nbsp; SyntaxError: Unexpected identifier I had simply removed the sendChat with just text while I was trouble shooting, the other lines of code that worked were 1 sendChat line and no others... just to cover my bases. Edit: It &nbsp;came up with that error before I could even use the API for the record. MoreEdits: Ugh I forgot a Curly bracket sorry about that testing now...
1591296645

Edited 1591296999
It doesn't error, it just doesn't roll :)&nbsp; Edit: I also tried it with my originalnaming too (been changing my Abilities to have simple lowercase and no special character just to be sure that wasn't the issue...) Edit: btw I did just try it with just the command and the &amp;#37; learning stuff as we go though, backticking apparently has superior features over quotes like allowing for variable queries in the middle of them :P instead of my concatenating them wiuth + signs. Good to know (had to look up what the $ sign do in javascript :)
Also as a side note I also tried making an attribute which in its field = %{charactername|roll} and tried just calling the attribute (@{charactername|attribute} and &amp;#64;{charactername|attribute} both fail to call the roll, the later does the same thing as above and just shows the command in chat) Weird is that inline rolling works for other parts (even though that DeflectMissilesCatch had those errors, I was still able to get the appropriate roll out of that section, with references to the character and attribute as normal.)
Were you able to fix it in the end? I'm facing exactly the same problem now.
Unfortunately I was not able to fix that issue and had to suffice with a more manual approach. I have an API that handles class resource usage and a sheetworker that handles long/short rest mechanics of resetting them. I have also changed my Community Contributed Character sheet significantly to accommodate this. While I would enjoy that feature I have moved on to other things that I could get to work. TLDR didn't fix, gave up