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 .
×

Communicating between rolls and action buttons

I'd like to have some buttons that both make rolls, and change attributes.  I'm having a hard time figuring out how, unless I just put everything into the API scripts. For instance, it would be good to have a button that will roll for attack+damage, and also decrease the weapon's ammo by one.  As far as I can tell, only roll buttons can trigger rolls (or other chat functions), and only sheetworkers can change attribute values.  So maybe I'd need a roll button that chains into a sheetworker? What I have in mind is something like <button type="roll" name="roll_attack" value="/r 1d10+@{attackBonus} ; %{spendAmmo} @{repeatingWeaponRowId}"></button> : the button triggers the /r roll, but also a sheetworker script that drops the ammo.  Preferably passing it an argument somehow so that it knows which row is firing. It would also be nice to have confirmation on some of the sheetworker actions, so an action button can reload (subtract some ammo from inventory, add it to the weapon's magazine) and note in chat to the party that it's done so. Are these sorts of things feasible with just the character sheet and sheetworkers, or do I need to have the sheet buttons just tell the API to do everything?
1607105332

Edited 1607105393
Andreas J.
Forum Champion
Sheet Author
Translator
To make both rolls and make changes to a stat with the same button press, you need to use API . There is no way around it, normal rolls cant edit stats or trigger sheetworkers, and action buttons can only trigger sheetworkers, but not do dice rolls. ChatSetAttr is a good one that can be embedded with an inline version into existing roll macros. The community wiki have examples of this, and my Stargate RPG char sheet have by default a few ChatSetAttr embedded in extra rolls found on the setting page.
Thank you!  Between roll buttons, action buttons, abilities, macros, sheetworkers, and the API, it's hard to get a sense of what communication lines are available!
1607181791
Andreas J.
Forum Champion
Sheet Author
Translator
these two pages are the best on the topic: <a href="https://wiki.roll20.net/Complete_Guide_to_Macros_%26_Rolls" rel="nofollow">https://wiki.roll20.net/Complete_Guide_to_Macros_%26_Rolls</a> <a href="https://wiki.roll20.net/Button" rel="nofollow">https://wiki.roll20.net/Button</a>
1607740656
mrianmerry
Pro
Sheet Author
Just out of interest, do we have a reason why &nbsp;buttons cannot both trigger a sheet worker and post a message to the chat log? (I presume some kind of "didn't code it like that", or perhaps to drive people towards a Pro subscription so they can use an API solution, or simply that we don't know...)