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

Send Chat Roll to Multiple Individuals

1563111164

Edited 1563113258
GM Michael
API Scripter
Using the API, how can you whisper the same chat roll to multiple individuals that may not all own the same token?  For example, character sheets apparently have the ability to whisper the same roll to multiple individuals through the Whisper to GM function.  How can the API do something similar?  Obviously, calling sendChat a second time would just generate a completely new message and perform a second roll, which wouldn't match the first one.  For my current purposes, just the ability to whisper to both the GM and a particular character would be sufficient, but I'd really like to know a more general solution.
1563124768

Edited 1563124798
GiGs
Pro
Sheet Author
API Scripter
The ways I can thing of doing this are a bit clunky. It also depends how you are calling the script. If you can include the roll in the script call, it's easy: you already have that roll, just build the output in the script and send it to everyone individually. (This is the easiest and most efficient way.) Or, you can have the script perform the roll silently, and retrieve the output, and send it to whoever needs to see it. This requires a bit of careful handling, since it is an asynchronous process. And the most convoluted way (never done this, not sure if it'll work): in your script, create a new character. Grant the relevant players edit control of the character. Have the roll be sent to that character (so all those players will see it). Then delete the character. I am not sure if this will fail due to async delays, but it's an amusing idea to try. Honestly, it would help more knowing the context: what does your script do, how is it called, etc.
1563128585

Edited 1563138900
GM Michael
API Scripter
It's to resolve a bug in SpellMaster.  The player clicks a cast link in the sheet and the resulting rolls are printed.  If the user has their sheet configured to whisper rolls, the rolls will be whispered to the character and the GM.  I naively used two sendChat calls, which means two different rolls and the player and GM disagreeing on the value, which is... Bad. Because I want it to be performant, the idea of it sending a message to itself is less than ideal. I really want the user to be able to have the classic roll display because while I built a basic roll parser for Mass Combat, I'd have to upgrade it to support advanced references, plus build the HTML manually. I'd considered the idea of building a character on startup that ownership could temporarily be assigned to, but that does introduce async frustrations if the user mashes the cast button or if two people attempt it at the same time.  Certainly doable, but it'd be annoying to write. More than anything, I really kinda expected there was some utility somewhere I hadn't found that would do this.  Sending messages to multiple recipients seems really basic.
1563138590
GiGs
Pro
Sheet Author
API Scripter
Michael G. said: More than anything, I really kinda expected there was some utility somewhere I hadn't found that would do this.  Sending messages to multiple recipients seems really basic. I agree, it does.
1563210148
The Aaron
Roll20 Production Team
API Scripter
The Character way is the best way. I believe you can create that character as Archived and still whisper to it. Establish a standard naming convention (I suggest sorting the ids and joining with : ) then write a routine to create all the possible names (great recursive operation) and verify a character for them exists on start up, creating it if it doesn't. Then in your script, you can assume their existence and just whisper to them. Bonus points for checking on('change:player:_online',...) and adding characters as needed.