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

API SendChat command

Hi everyone,
I'm trying to public a simple text in the Chat, but the command SendChat doesn't work. 
I checked the WikiRoll20 (Section API) but I didn't get how to create an API Script and I don't know how it works.
I'm not an expert, but what I'm trying to do is, for istance: when a character runs out of a value, I want the character sheet to public a message on Chat.
Can you help me?
Thanks a lot

May 24 (5 years ago)

Edited May 24 (5 years ago)

The most basic sendChat contains a from (eg "GM") and a content (eg, "text").

sendChat("GM","text");

will write text into the chat box as if from GM.  I'm afraid if you want this automated from the character sheet, that's more advanced that I can help with.


Hi,

to create a script, simply go to your game page (not the game itself), Settings --> API-Scripts. There you have to click at "New Script". Give it a name, write your JavaScript Code and hit save.

The sendChat is indeed the way to go, but you have to find the right trigger for your code. See at https://wiki.roll20.net/API:Events

If this doesn't help, try to look at official scripts (like "5th Edition OGL by Roll20 Companion"). This skript will reduce a Spell Slot on the character sheet (if you use the "5th Edition OGL by Roll20" sheet) and then post the new value into the chat. I'm pretty sure, if you find the right part of the code, you can copy-pase most of the code with little changes to your needs.


Hope this helps, if not, please clarify your problem a little more - which system do you use, which character sheet, what value exactly are you trying to access, and so on.