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 macros (TokenMod?) to set spell_save_dc attribute

Good afternoon. Hope everyone is staying sane in 2021 so far! At my "table", I use proficiency die and let PCs roll proficiency die at advantage when it comes to the spell_save_dc attribute. Currently I'm having to manually edit the field from 11+d8 to [[11+2d8kh1]] for every character sheet, usually before each game just in case something happens that reset it to its defaults, like leveling up or any changes to the spellcasting ability. My question is this; is there an easier way to do this using macros or api that could set it to something like [[ [[ 8 + @{spellcasting_ability} ]] + [[ { [[ 1@{pb} ]] , [[ 1@{pb} ]] } kh1 ]] ]] or is the above overly complicated for what I'm trying to do? Thank in advance! -Agnati
1621424909

Edited 1621424937
Andreas J.
Forum Champion
Sheet Author
Translator
Only API can edit token/character stats. ChatSetAttr could edit it for all sheets at the same time, with a single command, instead of the example [[ ]] (inline roll), use your expression instead. ! setattr - - all - - spell_save_dc | [[ [[ 8 + @{spellcasting_ability} ]] + [[ { [[ 1@{pb} ]] , [[ 1@{pb} ]] } kh1 ]] ]] the above could work, but I'd first try on doing it with one character: ! setattr - - charid @{target | character_id} - - spell_save_dc | [[ [[ 8 + @{spellcasting_ability} ]] + [[ { [[ 1@{pb} ]] , [[ 1@{pb} ]] } kh1 ]] ]]
Thanks for the reply, Andreas J! I'm getting the TypeError: Cannot read property 'substring' of undefined  using the formula provided (with the single-character one, it was a repeating error that filled the chat instantly. lol) I've tried subbing in the direct character id for one of the characters  I've also tried  ! setattr - - charid @{target | character_id} - - spell_save_dc |20 (static DC, also tried with the direct character id) with no error, but also no change to the attribute (and no crash of the api sandbox) Any thoughts?
1621455213

Edited 1621455334
Andreas J.
Forum Champion
Sheet Author
Translator
Try reference the character by name: !setattr --name John --spell_save_dc|20 Or try this, while having the token selected: ! setattr - - sel - - spell_save_dc |20 doing the selected token route, this might end up working: ! setattr - - sel - - spell_save_dc | [[ [[ 8 + @{selected|spellcasting_ability} ]] + [[ { [[ 1@{selected|pb} ]] , [[ 1@{selected|pb} ]] } kh1 ]] ]]
Progress! I was sleep deprived with your very first reply and missed the ChatSetAttr api part. Installing that like a competent person, the latter commands do modify the character sheet without error. Only issue is that it resolves the formula to it's value of 12 or 17 or whatever instead of [[11+2@{pb}kh1]] Any idea how to have it input the brackets instead of resolving the math? I know any other time, every other person would be asking for the opposite. heh. -Agnati
1621473282
Andreas J.
Forum Champion
Sheet Author
Translator
Maybe remove the outermost brackets? ! setattr - - sel - - spell_save_dc | [[ 8 + @{selected|spellcasting_ability} ]] + [[ { [[ 1@{selected|pb} ]] , [[ 1@{selected|pb} ]] } kh1 ]] What's the point of [[ { [[ 1@{selected|pb} ]] , [[ 1@{selected|pb} ]] } kh1 ]] , if it gonna end up as 2@{pb}kh1 ? And should the end result in the filed be: [[8+@{spellcasting_ability}+2@{pb}kh1]] or 8+@{spellcasting_ability}+2@{pb}kh1 ? After giving it a thought, you're probably looking for simply: !setattr --sel --spell_save_dc|8+@{spellcasting_ability}+2@{pb}kh1 where the attribute flatly becomes that value. Due to the API processing inline rolls, I think it can be hard to use it and set an attribute that is wrapped in [[ ]], as it would process it as an inline roll. There are likely ways around this, but don't know stuff that well.