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

[Help] Sending Chat Commands using a second Script.

1437524865

Edited 1437525573
I'm currently running a modified bloodied and wounded script and the Status Tracker Script (Found  here ). So my initial plan was to simply add to my bloodied and wounded script the following line. sendChat("","!StatusAdd Grazed -1 -1 to Attacks,Saving Throws, Skill Checks, Ability Checks, AC and Caster Level   // none"); After a lot of bug testing I've discovered the sendChat line is in the right location and sends the message which doesn't appear in the chat log but in the API log. However it doesn't trigger the Status Trackers Script like it should. I have checked and the message it sends when input manually triggers the Status Trackers Script. Can anyone help me figure out why it doesn't when input by the other script?
The sendChat function doesn't trigger chat:message handlers (presumably to prevent a sendChat call inside a chat:message handler from getting stuck in an infinite recursive call).  I recently added a wrapper around sendChat to Command Shell , which will execute Command Shell-aware commands.  If you retrofitted Status Tracker to register the !StatusAdd command with Command Shell, then you could use Shell.sendChat in place of the built-in sendChat to accomplish what you want.
1437537399
Lithl
Pro
Sheet Author
API Scripter
manveti said: The sendChat function doesn't trigger chat:message handlers (presumably to prevent a sendChat call inside a chat:message handler from getting stuck in an infinite recursive call). That's not been my experience. I have on several occasions triggered an infinite loop by being incautious with sendChat.
I went digging some more and assuming that Brian is right I may have found why. Can the SendChat function send as a GM level chat? Because the function might be restricted to GM only. Thanks for the responses guys.
1437542179

Edited 1437542240
The Aaron
Pro
API Scripter
Chats from the API have a user ID of API, IIRC.  playerIsGM() would surely return false for that.