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

Need help: How do I use a custom charsheet button to modify a player attribute (for example, to track ammo) Do I use ChatSetAttr?

I'm trying to do something fairly complex and need help understanding how to do it correctly. I made a custom charsheet for a homebrew campaign, I'm trying to automate the combat and skill checks as much as possible. Right now the charsheet has buttons for each skill, which use the "target" parameter to calculate DC when the player clicks the target of their ability. I'd also like to modify the attribute of the player (button clicker) during this process, because my homebrew has a resource called "Juice" which is awarded to players and can be expended to add a +1 to a roll for every point of Juice they add. I would like this amount of "Juice" (the amount they spent) to be automatically decremented from the spender's charsheet after expending it, rather than players having to manually decrement the value in their charsheet each time they expend Juice (which is very often) I thought I could use ChatSetAttr for this. Here is my current roll button. I know it's a mess. <button name="roll_sleightofhand" type="roll" value="&{template:default} {{name=Sleight of Hand}} {{Result=[[d20+(@{skill_sleightofhand}+@{dexterity_bonus}+?{How much Juice? (Max 3)|0})]]}} !setattr --sel --mod --Juice|-?{How much Juice? (Max 3)|0}!!! {{DC=[[10 @{target|Target|intelligence_bonus}+@{target|Target|skill_sleightofhand}]]}} {{Skill Level= @{skill_sleightofhand}}} {{DEX Bonus= @{dexterity_bonus}}}"></button> The relevant part here is that I put the ChatSetAttr script to reduce the Juice in the middle of the roll here: !setattr --sel --mod --Juice|-?{How much Juice? (Max 3)|0}!!! Here's the problem. ChatSetAttr has to have a character to reference, I'm using the --sel parameter (which just means "the selected token") BUT... the problem is that by the time the ChatSetAttr command runs, the player character's token has already been un-selected by the "target" parameter of the button (used to calculate DC), so ChatSetAttr displays an error that I have no character selected. This is probably a dumb way to do this but I'm running into a wall here, I thought ChatSetAttr would work but it doesn't. Is there a way that I can make a button that does the following things: -Calculates the modifiers on a roll (relevant skill level, relevant attribute) -Factors in a player-determined variable into the calculation every time the button is pressed (right now i'm doing this with a roll query, as you can see above) -Calculates target DC of targeted token that was clicked by player -(Most importantly, this is the part I can't get to work right now) modifies an attribute of the character who pressed the button, based on the variable previously entered by the player? Hopefully I've explained that well enough, sorry this is a long post.
1603656758
Andreas J.
Forum Champion
Sheet Author
Translator
Here is an example for how I built in automated healing into the Stargate character sheet: < button name =" roll_hd " type =" roll " title =" %{hd} " value =" @{whisper}&{template:stargate} {{color=green}} {{title=Short Rest}} @{show_name} !modbattr --silent --name @{character_name} --hp|{{Healing=[[@{hd}]]}}!!! {{desc=One roll of the Hit Dice.}} " > Short Rest </ button >
ᐰndreas J. said: Here is an example for how I built in automated healing into the Stargate character sheet: < button name =" roll_hd " type =" roll " title =" %{hd} " value =" @{whisper}&{template:stargate} {{color=green}} {{title=Short Rest}} @{show_name} !modbattr --silent --name @{character_name} --hp|{{Healing=[[@{hd}]]}}!!! {{desc=One roll of the Hit Dice.}} " > Short Rest </ button > This works perfectly, thank you. Using the @{character_name} as the selection parameter was just what I needed.