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

[SCRIPT] [5e OGL] [HOW-TO] Send, read and manipulate roll results from atkdamage template to send back a message and modify attributes with sheetworker.

I am using a script in which i have re-mapped my repeating attacks sub-attributes to send them back to the atkdmg template, with queries regarding if the attack is made with advantage, disadvantage, normal or always to feed the {{always=1}} where always is replaced by result of query, and if the attack is range with ammo, to select from query to choose ammo (list populated before query) and if thrown, to remove 1 from the item quantity. this works fine. I feed the templates and does everything I want to. NOW, what I want to add to that, is NOT sending the template back to chat, but sending it back to the script, so it can then check if the attack roll > target AC, remove damage roll from target HP, and send to chat  -- if success, a text with CHARNAME sucessfully hit TARGET NAME for [X] HP --if not a success, a text with CHARNAME tried to hit TARGET NAME, but missed. I have read about adding a callback when sending my template to chat, or 'listening' to chat messages for inline rolls and template or some KW I could send in there.  I am fairly new to programming (2 classes of Java, 1 class of javascript, css, html) but I usually get things quite quickly if it uses mostly logic. Thank you!
Also, please let me know if I posted in the right section. :)
1565570486
The Aaron
Roll20 Production Team
API Scripter
Seems like the right section.&nbsp; I'd love to help with this right now, but I'm on a bit of a work deadline. I'll try to point you in the right direction and check back when I'm not swamped. :/ These kinds of things are usually easier when you can post the code you have. It sounds like you have an API script which is properly receiving an API command from your sheet, but when you post the msg.content back to chat, it's not in a roll template. If that's the case, what you are missing is reading msg.rolltemplate and prepending it back to the message before sending.&nbsp; (see:&nbsp; <a href="https://wiki.roll20.net/API:Chat" rel="nofollow">https://wiki.roll20.net/API:Chat</a> )
Thank you Aaron. I have read so many of your posts, when we decided to look into customizing some scripts 2 weeks ago because of macro limitations, and that I was trying to figure out stuff. Big fan. Your work is of amazing quality, and you are a great mentor to all of us trying to program/code. I use Companion and PowerCards (modified) as well as InventoryTracker5eOGL scripts the latter the one I decided to build on and customize. Found it on the Gitub Roll20 scripts. I was looking for something to manage equipped inventory. Then looking through the code and trying to understand it, I liked the way it was structured and easy to modify. On a side note, I have also made this post regarding an issue when unchecking the _hasattack attribute with sheetworker --&gt;&nbsp; <a href="https://app.roll20.net/forum/post/7678155/5e-ogl-help-setwithworker-on-hasattack-attribute-not-adding-the-item-to-attacks-and-spellcasting-section" rel="nofollow">https://app.roll20.net/forum/post/7678155/5e-ogl-help-setwithworker-on-hasattack-attribute-not-adding-the-item-to-attacks-and-spellcasting-section</a> So, right now, I am delving myself into understanding how to catch my template when I send it to chat. My atkdmg template mapping with querries is in my modified powercard script, which I am moving to my modified InventoryTracker5eOGL script, which will make it faster, simpler, especially in regards to separating melee attacks from ranged attacks and thow attacks (And Spell, and maybe some Other), one of the reason being I use a querry to populate the ammo=ammo section of the 5e OGL&nbsp; atkdmg template among others.&nbsp; So from what I understand from the documentation, I use something like :&nbsp; sendChat("Riley", "&amp;{template:atkdmg...(filled by my values)", function(ops)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Then, this is where I am not sure, in my script, i would do : on("chat:message", function(msg) {&nbsp; &nbsp; &nbsp;// I know something would be missing here. **Read the input and do operations to split wanted values** **Make check vs AC (found because template will trigger a @[target|character_id}, from which I will extract the AC** **Check if the attack was succesful** **On success, take the damage that was rolled (I am on auto roll damage and crit) and remove it from target character with sheetworker and send message with the damage that was done ** **On fail send message that the attack missed ** } I will attempt to add this to my script maybe this week, and will post code. Just attempting to grasp how I will proceed before coding it, because sometimes you might have to re-do everything.&nbsp; I never expect help and rarely reach out for it, or, at least, I will usually try exhaustively before doing so. Although I read a lot from the forums, I just made my first posts in the last few days, as I didn't fully understand how&nbsp; to use callback from documentation. And how I interpret that back into the script. Felt like this would be a big drawback for when I would reach that part.&nbsp; Sorry for the long post.&nbsp;