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

SheetWorkers, Roll Buttons and Repeating Sections

Hi all! Is there any way to trigger sheetworker on roll button click? Furthermore, is it possible for buttons inside a repeating section? 
1565211590
The Aaron
Roll20 Production Team
API Scripter
You can't trigger sheet workers from a roll, but you can trigger api scripts from them, and then propagate the event to sheet workers by setting an attribute using .setWithWorker().  You can have rolls in repeating groups. 
but you can trigger api scripts from them How exactly would that work? Like adding !scriptcommad to value of a roll button, so that text would appear in chat and API script can react? 
1565211935

Edited 1565211992
GiGs
Pro
Sheet Author
API Scripter
There are roll buttons, and action buttons. You can trigger a sheet worker off an action button, but this cannot print anything into chat. Roll buttons can post things into chat (like dice rolls), but can't trigger sheet workers. You can also disguise checkboxes to look like buttons, and have them change an attribute, which triggers a sheet worker. But that is like an action button - it cant print anything to chat, either. So the answer is either yes or no, depending on what you want the button or sheet worker to do. The answer is the same for inside repeating sections as outside. What are you wanting to do? Edit: ninja'd!
1565212013
GiGs
Pro
Sheet Author
API Scripter
Stoum said: but you can trigger api scripts from them How exactly would that work? Like adding !scriptcommad to value of a roll button, so that text would appear in chat and API script can react?  Yes, exactly.
1565212239
The Aaron
Roll20 Production Team
API Scripter
GiGs said: Stoum said: but you can trigger api scripts from them How exactly would that work? Like adding !scriptcommad to value of a roll button, so that text would appear in chat and API script can react?  Yes, exactly. Or you can monitor all chat messages and look for a given template, or match a string, etc. Doesn't have to be an API command. 
GiGs said: So the answer is either yes or no, depending on what you want the button or sheet worker to do. What are you wanting to do? First of all, I want to track uses of all skills of players, in order to calculate them at the end of the session and award improvements points (it's a cyberpunk2020 thing). The skill use is obviously a roll, and number of uses should be stored in a hidden attribute.  And then I want to track ammo of several guns stored in a repeating section. So I think the approach of sending and detecting something in chat will do it, thanks. But the question is - can I send something not visible to players (preferably not visible to me either) to not spam down the chat and will it be detectable by scripts? 
1565213458

Edited 1565213709
GiGs
Pro
Sheet Author
API Scripter
That might be better disconnected from the character sheet, and made as its own separate script. As Aaron suggests, you could have a script silently running, monitoring chat, and gathering information from the rolls made and attributes changed. It could also monitor the ammo attributes for changes. You can activate it and deactivate it with your own script command, dont through a macro, and store the information it needs in various ways: use a hidded attribute on the character's sheets, use a dedicated GM sheet for this, use the API state (a special data storage area that persists through campaign loads, just like attribute values). Edit:  that said, making each roll button send a command that triggers a script which does the skill roll, and stores the information, would make the programming a lot easier, i think.
GiGs said: Edit:  that said, making each roll button send a command that triggers a script which does the skill roll, and stores the information, would make the programming a lot easier, i think. So is it possible to pass some information to chat with default roll buttons? I figured out that roll templates are supported, but can I somehow execute multiline roll from the button? I can probably build custom template with hidden attributes, but I'd rather not.  Also, regarding repeating sections - is there a way to reference repeating item ID from inside the sheet? 
1565217546
GiGs
Pro
Sheet Author
API Scripter
A standard roll button's only purpose is to send things to chat. Whatever you put in the value gets printed in chat. Usually its used for a roll, or rolltemplate, but it can be a script command, just text, or some combination of all of these. You can put linebreaks in the value using '\n' (or is it '/n' ? I can never remember till I'm actually coding.) For repeating sections, if you are just making a roll, you dont need to use the repeating id. You  could  reference the id (easiest - for some value of easy - way would be to have a sheet worker grab the roll id in a hidden attribute, and your roll include that value). But if you are using a script to track skill usage, you might not need the repeating id. Just store the skill name. Remember, if using a script, you dont have to store the usage information on the same character sheet - you could store it separately, and in which case you probably only need the character name or id, and the skill name. If improvement points must go directly to the specific skill that is rolled, storing the information in the same character sheet and repeating row makes sense. If its more like a single xp total, the way I'm describing here might be better. But either way, yes, you can do it. I'm just throwing out options here, since I;m lacking full details on what you need to do.
GiGs said: For repeating sections, if you are just making a roll, you dont need to use the repeating id. You  could  reference the id (easiest - for some value of easy - way would be to have a sheet worker grab the roll id in a hidden attribute, and your roll include that value). Wow, I haven't thought of that. Thank you, I think I have everything to go do some coding :)