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

Sheet Workers and Chat

1486114107
David
Sheet Author
Is it possible to send something to the chat from a sheet worker?
1486116179
Kryx
Pro
Sheet Author
API Scripter
As far as I'm aware, no. It would be really nice if it were possible.
1486116506
David
Sheet Author
I see you cannot do an alert either, which means there is no way of alerting a player to the fact that a change has been made to their character sheet.
1486116608
Kryx
Pro
Sheet Author
API Scripter
Indeed. I built my own notification system to inform uses. I can share it if you'd like.
1486117497
David
Sheet Author
I was digging around in your 5e shaped sheet hoping your would have an answer in there, does your notification system use the the API?
1486118168
Kryx
Pro
Sheet Author
API Scripter
I use it to inform users of version changes. Here is a simplified version: <div class="sheet-wrapper"> <input type="hidden" name="attr_processing" class="show-processing" value=""> <div class="processing"> <span name="attr_processing"></span> <div class="center"> <label class="pseudo-button-wrapper visible-button"> <input type="checkbox" name="attr_close_processing" value="1"> <span data-i18n="CLOSE"></span> </label> </div> </div> </div> // css for showing/hiding processing .sheet-processing { background-color: $transparent-black; border-radius: $border-radius; color: $off-white; display: none; padding: 2px; position: absolute; right: -15px; top: -30px; width: 215px; z-index: 99999; } .sheet-show-processing:not([value='']) ~ .sheet-processing { display: block; } .sheet-wrapper { position: relative; } // sheet workers for closing close() { getSetItems('Processing.close', { collectionArray: ['processing'], callback: (data) => { data.processing = ''; }, }); } setup() { on('change:close_processing', () => { this.close(); }); } It's written in ES6 with some wrappers, but the concept should be understandable. You can then show anything in that box by changing the "processing" field. The user can then close the window via the close_processing pseudo button.
1486120811
David
Sheet Author
Thank you for the code. The sheet workers seem to be throwing unexpected token errors.
1486121182
Kryx
Pro
Sheet Author
API Scripter
Ya, you can't copy+paste it directly. It's ES6 which is modern Javascript, but not all browsers support it yet. function close() { // set data.processing = ''; } function setup() { on('change:close_processing', function () { close(); }); } setup(); That may work.
1486123616
David
Sheet Author
Ok I got it working I had to add an onchange for the check box to set the message to blank when it was checked, because the show hiding/processes  css keys off the content of the processing input.  Was that the correct thing to do?  Thanks for all your help
1486123721
Kryx
Pro
Sheet Author
API Scripter
Exactly. That's what the sheetworkers above does - it clears the processing field.
1486124310
David
Sheet Author
I added a console output to credit you and I will add another credit in the readme.
1486124380
Kryx
Pro
Sheet Author
API Scripter
Ah, I don't need credit. I'm glad I could help!