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

ROLL & execute a worker function with one button click

1585394281

Edited 1585395326
Hello, My custom charactersheet has a button to use a character's ability.  When the button is pressed, I want it to perform 2 tasks: Decrease by 1 the amount of available uses for the ability. Roll the ability dice. As far as I can see, we are allowed to use two types of  buttons: type="roll" type="action" With the first one, roll20 executes a roll, e.g. <button type="roll" name="roll_class_ability1" value="/roll 1d20"></button> With the second one, we can set up a click listener on the worker, e.g. <button type="action" name="act_class_ability1" ></button> <script type="text/worker"> on("clicked:class_ability1", function() {     console.log("spent class ability 1"); }); </script> I want both things to happen simultaneously (with only one click).  So far I have tried without success: Execute a roll from the worker function (doesn't seem to be possible). Listen for the click of the button with type="roll" (doesn't seem to be possible). Listen for the "mousedown" and "mouseup" of the button with type="roll" (they don't seem to get binded). Overlap two invisible buttons of each type, one on top of each other (only the top one receives the click, event propagation seems to be cancelled). I think that it is a common thing to be expected from a charactersheet.  I am pretty sure that someone has already faced this problem and solved. Thanks for your help in advance!
1585396384

Edited 1585396472
GiGs
Pro
Sheet Author
API Scripter
Iniciativa +. said: Hello, My custom charactersheet has a button to use a character's ability.  When the button is pressed, I want it to perform 2 tasks: Decrease by 1 the amount of available uses for the ability. Roll the ability dice. What you want is unfortunately impossible on roll20. You can do one or the other, you cant do both with the same button. The only way to do this is with a custom API script, which means the GM pf the campaign must be a pro subscriber. I think that it is a common thing to be expected from a charactersheet.  I am pretty sure that someone has already faced this problem and solved. Thanks for your help in advance! You are absolutely correct that this is a common thing to want. The reason that no character sheet does this, is because it can't be done. Sadly.
1585398893

Edited 1585398962
Thanks for your quick reply GiGs !  Would it be possible to request the feature to the roll20 team? Meantime, I will explore custom API scripts.  If anyone has any advise or examples to point me to, that would be more than appreciated.
1585401772
GiGs
Pro
Sheet Author
API Scripter
There's a Suggestion forum to make your desired features known. Do a search to see if this one exists already. The ammo and chatsetattr script are both good for modifying expendable resources, and you can include their commands in a macro that rolls dice.
1585425571
vÍnce
Pro
Sheet Author
How I wish this was an option for sheetworkers!  Thinking of you "Dice pool" game system/sheets...