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

ChatSetAttr Question in Nesting Macro

1717288946

Edited 1717388632
Rogue
Pro
Marketplace Creator
Hello, is there a way I could use this API script to automatically subtract the amount of a Chi drain that is rolled from the characters Chi Pool which is located in their blue bubble. The nested macro looks like this. It pulls up all of their attack method options, attacking with a chi strike is one of them. I dont need to see the amount, just as long as it is automatically taken from the blue bubble or the Attribute known as: Chi &{template:two-part} {{name=Attack Roll}} {{character=@{character_name}}} {{text=Attack:?{Form of Attack |Unarmed,[[d20+@{selected|UnarmedHit}+@{selected|UnarmedHitBonus}@{PhysMod}+?{Modifier|0} [Unarmed] ]] **Unarmed** |@{AltUnarmedName},[[d20+@{selected|AltUnarmedHit}+@{selected|AltUnarmedHitBonus}@{PhysMod}+?{Modifier|0} [@{AltUnarmedName}] ]] **@{AltUnarmedName}** **Chi Drain:** *[[d6]]* |@{Weapon1Name}, [[d20+@{selected|Weapon1Hit}+@{selected|Weapon1HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon1Name}_Attack] ]] **@{Weapon1Name}** |@{Weapon2Name}, [[d20+@{selected|Weapon2Hit}+@{selected|Weapon2HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon2Name}_Attack] ]] **@{Weapon2Name}** |@{Weapon3Name}, [[d20+@{selected|Weapon3Hit}+@{selected|Weapon3HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon3Name}_Attack] ]] **@{Weapon3Name}** |@{Weapon4Name}, [[d20+@{selected|Weapon4Hit}+@{selected|Weapon4HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon4Name}_Attack] ]] **@{Weapon4Name}** |@{Weapon5Name}, [[d20+@{selected|Weapon5Hit}+@{selected|Weapon5HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon5Name}_Attack] ]] **@{Weapon5Name}** |@{Weapon6Name}, [[d20+@{selected|Weapon6Hit}+@{selected|Weapon6HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon6Name}_Attack] ]] **@{Weapon6Name}** }}} {{supplementary=**Actions:** ?{Actions|1}}}
1717289114

Edited 1717388587
Rogue
Pro
Marketplace Creator
I also have the same question for mana drain. This would be implemented for each spell which is a set amount of mana drain for each spell. Using a token macro it pulls up all your spells and you click on the spell and cast it. I was wondering about using the API script to automatically remove their mana drain according to the spell they have chosen. Is this even possible with the ChatSetAtt API script or is anyone aware of one that will help me out? This one I need to remove the amount of drain which the attribute would be called Spell1Drain   &{template:simple} {{name=@{character_name} Cast Check}} {{text=?{Spell List |@{Spell1Name},[[d20+@{selected|Spell1HitMod}@{MenMod}+?{Modifier|0} [@{Spell1Name}_Cast] ]] **@{Spell1Name}** Mana Drain: **@{Spell1Drain}**  Area: **@{Spell1Area}** Magic Actions: **@{Spell1Act}** |@{Spell2Name},[[d20+@{selected|Spell2HitMod}@{MenMod}+?{Modifier|0} [@{Spell2Name}_Cast] ]] **@{Spell2Name}** Mana Drain: **@{Spell2Drain}** Area: **@{Spell2Area}**  Magic Actions: **@{Spell2Act}** |@{Spell3Name},[[d20+@{selected|Spell3HitMod}@{MenMod}+?{Modifier|0} [@{Spell3Name}_Cast] ]] **@{Spell3Name}** Mana Drain: **@{Spell3Drain}** Area: **@{Spell3Area}**  Magic Actions: **@{Spell3Act}** |@{Spell4Name},[[d20+@{selected|Spell4HitMod}@{MenMod}+?{Modifier|0} [@{Spell4Name}_Cast] ]] **@{Spell4Name}** Mana Drain: **@{Spell4Drain}** Area: **@{Spell4Area}**  Magic Actions: **@{Spell4Act}** |@{Spell5Name},[[d20+@{selected|Spell5HitMod}@{MenMod}+?{Modifier|0} [@{Spell5Name}_Cast] ]] **@{Spell5Name}** Mana Drain: **@{Spell5Drain}** Area: **@{Spell5Area}**  Magic Actions: **@{Spell5Act}** |@{Spell6Name},[[d20+@{selected|Spell6HitMod}@{MenMod}+?{Modifier|0} [@{Spell6Name}_Cast] ]] **@{Spell6Name}** Mana Drain: **@{Spell6Drain}** Area: **@{Spell6Area}**  Magic Actions: **@{Spell6Act}** |@{Spell7Name},[[d20+@{selected|Spell7HitMod}@{MenMod}+?{Modifier|0} [@{Spell7Name}_Cast] ]] **@{Spell7Name}** Mana Drain: **@{Spell7Drain}** Area: **@{Spell7Area}**  Magic Actions: **@{Spell7Act}** |@{Spell8Name},[[d20+@{selected|Spell8HitMod}@{MenMod}+?{Modifier|0} [@{Spell8Name}_Cast] ]] **@{Spell8Name}** Mana Drain: **@{Spell8Drain}** Area: **@{Spell8Area}**  Magic Actions: **@{Spell8Act}** |@{Spell9Name},[[d20+@{selected|Spell9HitMod}@{MenMod}+?{Modifier|0} [@{Spell9Name}_Cast] ]] **@{Spell9Name}** Mana Drain: **@{Spell9Drain}** Area: **@{Spell9Area}**  Magic Actions: **@{Spell9Act}** |@{Spell10Name},[[d20+@{selected|Spell10HitMod}@{MenMod}+?{Modifier|0} [@{Spell10Name}_Cast] ]] **@{Spell10Name}** Mana Drain: **@{Spell10Drain}** Area: **@{Spell10Area}**  Magic Actions: **@{Spell10Act}** } }}
1718813805
timmaugh
Forum Champion
API Scripter
ChatSetAttr will work in a standard message (one directly intended for the chat rather than the Script Moderator)... you just have to close it with three bangs: !setattr ...options here... !!! You can place that within a roll query (this is what I think you're referring to when you say, "nested"), so long as you follow normal escaping rules for the query. That is, queries are made up of a prompt followed by options. The options can each be just a single item (the text you pick from the list is the text you drop into your command line), or they can be a label/value pair (where the query displays all of the labels for you to choose from, but the text that makes it to the command line is the value associated with that option). Options in a query are separated by vertical pipes, while label/value pairs are separated by commas. Then there is the ending brace of the query (the right brace enclosing the last option of the query). If any text in your prompt, label, or value would contain a pipe, comma, or right-brace... AND if that pipe, comma, or right-brace is NOT part of a sheet call (like getting an attribute from a character sheet), then that text will have to be replaced with its HTML equivalent: |    =>    | ,    =>    , }    =>    } So you can place your ChatSetAttr call in the value portion of your query, enclose it between ! and !!!, and do any HTML substitutions you need to so that your query doesn't break. Attributes (and sheet calls) will resolve first (that's why they don't break the query), then the query will resolve... leaving the appropriate ChatSetAttr command in the command line. Then ChatSetAttr will be notified that there is a message, and it will see the command buried in the text. One caveat about this... ChatSetAttr sees the message concurrently with the message hitting the chat window, so it doesn't have the ability to modify the message before you see it. That means it can't remove its own verbiage from the command line (removing everything between the ! and the !!!)... so that CSA text, if you leave your line structured as it is, now, will still be in the template when you see the message in chat. To get around this, people typically bury the CSA command between (or just outside of) template parts. Currently, your template part is: {{text= ... query result here }} Those last 2 braces, which close the template part, are *outside* of your query, so the template part doesn't close until after your query syntax is finished. That's why, with your line structured the way it is, now, you can't hide the CSA syntax. But by moving the closing double braces *within* the query, you can continue the value portion of each option to include the CSA syntax. To do that, you'll have to... perform the HTML replacements on the braces, so you'll be placing "}}" (without the quotes) include the HTML-substituted braces in each option of the query, regardless of if they have a CSA command or not -- they all need to close that template part So, just as an example, here is the template part with the first two items from your query. The second item in the query looks like it should have the Chi drain that would require the CSA command, so I'll include that in the second one: {{text=Attack:?{Form of Attack |Unarmed,[[d20+@{selected|UnarmedHit}+@{selected|UnarmedHitBonus}@{PhysMod}+?{Modifier|0} [Unarmed] ]] **Unarmed**}} |@{AltUnarmedName},[[d20+@{selected|AltUnarmedHit}+@{selected|AltUnarmedHitBonus}@{PhysMod}+?{Modifier|0} [@{AltUnarmedName}] ]] **@{AltUnarmedName}** **Chi Drain:** *[[d6]]*}}!setattr ...csa options... !!! |... Each option closes the template part, but the second then continues on to provide a CSA command. Since that command will now fall OUTSIDE of the template part, you won't see it in the final rendering of the message that makes it to the chat output. If it were me, I would: move the braces into the query for each option determine, on its own, what command parameters will make the appropriate change to the character sheet as is necessary for each option of the query where CSA is needed perform any HTML substitutions on that command, and insert it where it needs to be in the query That should get you sorted.