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

Is it possible for a script to read text from chat

I've been searching for a few hours for a script that can read text from chat and then run a macro based on what it's read. But my lack of success is leading me to believe this might not be possible. My idea scenario is for a script to be able to respond to someone posting "[char_name] is: [condition]" and parse that to a macro that does something like !token-mod --set @{char|[char_name]} condition|[condition]
1619615937
The Aaron
Roll20 Production Team
API Scripter
It's definitely possible.  The API would listen to on('chat:message',...) events, and parse the msg.content looking for that pattern.
1619620608

Edited 1619620720
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There's actually a script in the repo that does just that: Customizable Roll Listener. It "listens" for patterns in the text (though IIRC, it might be limited to text presented within roll templates), and runs a specified macro when it occurs. It sounds like you need a bit more control than that, but there may be code you can pillage. You can also look into Combat Manager, which has some of the condition assignment capability you are looking for.
1619625795
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, CRL does pretty much this, while it couldn't dynamically do what you want, you could set up rules in CRL for each condition that would do what you want. CRL doesn't need a roll template to be in the chat message, but can filter messages to respond to based on the template used.
I really wish that somehow we could get a "Show the players the last roll API script lol.  How many times have you whispered something and wanted to show the roll?  Also the group check instance where you have to do the math cause everyone rolled seperately.  Wish my players would trust the group check api command but they don't, and I have to do math in my head cause of it.  
Oh, amazing. I'll look into CRL today and see if I can get it to do what I want. Heck, knowing it's possible  is a big help! Thanks all!