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

Using a Query to roll an extra dice and reduce an attribute by 1

Hi, Can someone help me with a macro, I'm managing to do the query yes/no if yes roll +1d6 but is there something that can be added to reduce an attribute to help track the extra dice that have been spent? What I have currently  /roll 1d4!+?{Spend extra dice?|No,0|Yes,d6!} So when yes is selected I want a attribute to reduce by 1 as well as roll the extra dice Thank you
1652643472
Andrew R.
Pro
Sheet Author
You’ll need to use an API script like TokenMod or CharSetAttr to do that. The macro system cannot change tokens or character sheet attributes. 
I thought you could as I could find this post&nbsp; <a href="https://app.roll20.net/forum/post/7482067/can-we-use-macros-to-increase-or-decrease-the-value-of-the-attributes-on-the-sheet" rel="nofollow">https://app.roll20.net/forum/post/7482067/can-we-use-macros-to-increase-or-decrease-the-value-of-the-attributes-on-the-sheet</a> &nbsp;but couldn't figure out how to get it to work
1652725170

Edited 1652725401
David M.
Pro
API Scripter
Those examples use the two api scripts that Andrew mentioned. You first would need to install those scripts to your game. Both are available for 1-click install. EDIT &nbsp;- that being said, since there seems to be conditional logic involved (only updating the attribute for some cases), this might be best handled with something like scriptcards .
thank you., I'm very new to trying to do this so do need things explained to me simply. So I've looked at script cards and got to this but it's still not doing what I want, it's just rolling the 1d4+1d6 regardless of what is selected in the query box and not reducing the attribute, any help welcome. I'm not 100% sure this is the best way to do it but is seemed to be using the Conditional Statement part of script cards. !scriptcard&nbsp; {{ &nbsp; --#title|1d4 &nbsp; --=SpendDice|?{Spend Dice?|No|Yes} &nbsp; --?[$SpendDice] -inc No|[ &nbsp; &nbsp; --&amp;Value|Yep! &nbsp; &nbsp; --+| &nbsp; &nbsp; --=DiceRoll|1d4! &nbsp; &nbsp; --+Dice roll|totals [$DiceRoll] --]|[ &nbsp; &nbsp; --&amp;Value|Nope &nbsp; &nbsp; --+| &nbsp; &nbsp; --=DiceRoll|1d4!+1d6! &nbsp; &nbsp; --+Dice roll|totals [$DiceRoll] &nbsp; &nbsp; --@alter|_character name|@[character|character_name} @ResourceDice| -1 &nbsp; --]| &nbsp;}}
1652739548
David M.
Pro
API Scripter
Looks like you are trying to assign a string value ("Yes" or "No") to a roll variable. SpendDice should be defined with an ampersand to make it a string variable: --&amp;SpendDice|?{Spend Dice?|No|Yes} and referenced similarly [&amp;SpendDice]
Thank you David, that fixed the rolling. I still can't get the attribute to reduce not matter what I try, any suggestions? I've tried, things along the line of below but nothing seems to work, I linked Resource dice to bar 3 on the token to try and help&nbsp;&nbsp; &nbsp; &nbsp; --@alter|_character_name|@{Jonki|character_name} _bar|3 _amount|-1 &nbsp; &nbsp; --@alter|_selected|@{selected|token_id} _bar|3 _amount|-1 &nbsp; &nbsp; --@alter|_target|@{target|token_id} _bar|3 _amount|-1 &nbsp; &nbsp; --@alter|_selected|@{selected|token_id} _ResourceDice _amount|-1
1652800178
David M.
Pro
API Scripter
Do you have AlterBars installed? I've never used that script so not sure about its syntax.&nbsp; If you want to try the ChatSetAttr script to make sheet attribute changes, then something like this might work --@modattr|_name Jonki _ResourceDie|-1 Or, if you wanted to generalize it for a selected token, you could try something like this (though note this would require the SelectManager script to preserve the selected token form within the scriptcard): --@forselected|modattr _sel _ResourceDie|-1 Disclaimer: this is untested air coding
Thank you again for the help but I'm sad to say it's still not working. Any other ideas? I'm at a lose at this point
1652814605
David M.
Pro
API Scripter
Ross, the following works for me. Requires: Scriptcards, ChatSetAttr, and SelectManager scripts !scriptcard {{ --#title|1d4 --&amp;SpendDice|?{Spend Dice?|No|Yes} --?[&amp;SpendDice] -inc No|[ --=DiceRoll|1d4! --+Dice roll|totals [$DiceRoll] --]|[ --=DiceRoll|1d4!+1d6! --+Dice roll|totals [$DiceRoll] --@forselected|modattr _sel _ResourceDie|-1 --]| }}