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

Can 'sendChat()' accept the same string as clicking on a character sheet?

I am trying to script the equivalent of clicking on a character sheet. Is there some special formatting or options that I need to pass?  For example, I send "/me does a thing to @{selected|token_id}" and what I see is the emote formatting of "PintAndPie does a thing to @{selected|token_id}".
1564711139
The Aaron
Roll20 Production Team
API Scripter
I'm not sure what you're asking here.  @{selected|...} and @{target|...} will not work when issued by the API.  You'd need to pull the selected tokens out of message.selected array, and there is no @{target|...} equivalent.
Basically, I want to cut&paste what I see in the UI chat history and re-run it through the sendChat() script method. Not possible?
1564743773
GiGs
Pro
Sheet Author
API Scripter
It's possible, but you almost certainly need to make some edits to the text for it to fit the script context.  As Aaron observes, any selected or target keywords will need to be changed for the relevant id or character name (which the script can do), and there might be other changes needed.
1564746744
The Aaron
Roll20 Production Team
API Scripter
If you're talking about manually copy/pasting the command, you'll get it with all the attribute references and such which can be converted to make a generic version the API can issue.  If you're talking about the API observing messages in chat via on('chat:message,...), it will only see the result after substitution (no @{} references, etc). If you look at my OnMyTurn script, it has a function to deal with fixing up character ability/macro text which would probably be what you need, or at least a starting point.