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

Is there an API Script that would remove a rolled result from this token macro

1770705796
Rogue
Pro
Marketplace Creator
In the game Demon Gate, monks roll for chi drain when they attack. I have set up a macro that rolls the attack die and the drain die at the same time. I would love to also be able to have a script perhaps that would also drain what was rolled from their Chi Pool. Is this possible within this macro here? Each of these below are weapon slots on the sheet so I'm specifically looking for a way to add it into the AltUnarmedName attack right after **Chi Drain** *[[d6]]*  &{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}}}
1770705979
Rogue
Pro
Marketplace Creator
 it comes out looking like this 
1770748466
Gauss
Forum Champion
Hi Rogue,  I am a bit confused regarding what you want. You want to "remove" the roll from the result? Ie: it isn't in the output? OR You want to deduct the roll from the Chi Pool?  OR something else?  If you want it to deduct from an attribute ChatSetAttr can do that. 
1770774791
Rogue
Pro
Marketplace Creator
Yeah I want to deduct whatever is rolled on the chi drain from the chi pool of the character. I'm wondering if ChatSetAttr will allow me to add the command into the token macro.  **@{AltUnarmedName}** **Chi Drain:** *[[d6]]*
1771203879

Edited 1771204366
Gauss
Forum Champion
Here you go (sorry for the delay):  &{template:two-part} {{name=Attack Roll}} {{character=@{character_name}}} {{text=Attack:?{Form of Attack|Unarmed,[[d20+@{selected|UnarmedHit}+@{selected|UnarmedHitBonus}@{PhysMod}+?{Modifier|0} [Unarmed] ]] %NEWLINE%%NEWLINE%**Unarmed**}}|@{AltUnarmedName},[[d20+@{selected|AltUnarmedHit}+@{selected|AltUnarmedHitBonus}@{PhysMod}+?{Modifier|0} [@{AltUnarmedName}] ]] %NEWLINE%%NEWLINE%**@{AltUnarmedName}** %NEWLINE%%NEWLINE%**Chi Drain:** $[[1.computed]]%NEWLINE%%NEWLINE%**Chi Remaining:** $[[2.computed]]}}!setattr --name @{selected|character_name} --Chi|[[@{selected|Chi}[[-1d6]]]]!!!|@{Weapon1Name}, [[d20+@{selected|Weapon1Hit}+@{selected|Weapon1HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon1Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon1Name}**}}|@{Weapon2Name}, [[d20+@{selected|Weapon2Hit}+@{selected|Weapon2HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon2Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon2Name}**}}|@{Weapon3Name}, [[d20+@{selected|Weapon3Hit}+@{selected|Weapon3HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon3Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon3Name}**}}|@{Weapon4Name}, [[d20+@{selected|Weapon4Hit}+@{selected|Weapon4HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon4Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon4Name}**}}|@{Weapon5Name}, [[d20+@{selected|Weapon5Hit}+@{selected|Weapon5HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon5Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon5Name}**}}|@{Weapon6Name}, [[d20+@{selected|Weapon6Hit}+@{selected|Weapon6HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon6Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon6Name}** }}} {{supplementary=**Actions:** ?{Actions|1}}} Some notes:  This may be harder for you to modify in the future. Feel free to message me if that is the case.  I had to make some significant alterations to the code, but I didn't change the basic structure.  If you do need to edit it, you can separate things out by line like you had it while editing but you MUST reverse that before finishing the edit. I had to move the }} into the query thus necessitating HTML entities such as "}" (without quotes). That means we cannot have things on separate lines anymore.  It is also why I added all the %NEWLINE% commands. Also, I was only able to test two of the attacks, so please test all of the attacks and report any issues. If there are issues please PM me an invite so I can come test it with your sheet. 
1771205289

Edited 1771205618
Gauss
Forum Champion
Breaking down the changes:  Here we have the "Unarmed" section of the query as you wrote it:  |Unarmed,[[d20+@{selected|UnarmedHit}+@{selected|UnarmedHitBonus}@{PhysMod}+?{Modifier|0} [Unarmed] ]] **Unarmed** This is the rewrite: |Unarmed,[[d20+@{selected|UnarmedHit}+@{selected|UnarmedHitBonus}@{PhysMod}+?{Modifier|0} [Unarmed] ]] %NEWLINE%%NEWLINE% **Unarmed** }} %NEWLINE%%NEWLINE% replaces your space between the first and second lines.  }}  replaces the "}}" (without quotes) that existed at the end of the entire query. I had to move them inside the query due to the ChatSetAttr.  All of the other sections have these changes except for Alt Unarmed which has these changes and then some. Here is the Alt Unarmed:  |@{AltUnarmedName},[[d20+@{selected|AltUnarmedHit}+@{selected|AltUnarmedHitBonus}@{PhysMod}+?{Modifier|0} [@{AltUnarmedName}] ]] %NEWLINE%%NEWLINE% **@{AltUnarmedName}** %NEWLINE%%NEWLINE% **Chi Drain:** $[[1.computed]]%NEWLINE%%NEWLINE%**Chi Remaining:** $[[2.computed]] }} !setattr --name @{selected|character_name} --Chi|[[@{selected|Chi}[[-1d6]]]]!!! The bolded is again replacing elements you had.  And here are the new elements: |@{AltUnarmedName},[[d20+@{selected|AltUnarmedHit}+@{selected|AltUnarmedHitBonus}@{PhysMod}+?{Modifier|0} [@{AltUnarmedName}] ]] %NEWLINE%%NEWLINE%**@{AltUnarmedName}**%NEWLINE%%NEWLINE%**Chi Drain:** $[[1.computed]]%NEWLINE%%NEWLINE%**Chi Remaining:** $[[2.computed]] }} !setattr --name @{selected|character_name} --Chi|[[@{selected|Chi}[[-1d6]]]]!!! I provided a Chi Remaining section so you see what the Chi should be after Chi Drain.  $[[#.computed]] pulls the values that are rolled and calculated later on. Specifically the -1d6 and then the @{selected|Chi}-1d6 values.  This is the ChatSetAttr command:  !setattr --name @{selected|character_name} --Chi|[[@{selected|Chi}[[-1d6]]]]!!!
1771302651
Rogue
Pro
Marketplace Creator
First, thanks so much for doing this! It appears it is partly working except it is only taking 1 chi each time the character attacks instead of rolling a d6 and taking the result 
1771302664
Rogue
Pro
Marketplace Creator
1771311660

Edited 1771311698
Gauss
Forum Champion
I found the error, I made a formatting change without adequately testing and of course, it broke it. I should have known better. LOL Here it is corrected:  &{template:two-part} {{name=Attack Roll}} {{character=@{character_name}}} {{text=Attack:?{Form of Attack|Unarmed,[[d20+@{selected|UnarmedHit}+@{selected|UnarmedHitBonus}@{PhysMod}+?{Modifier|0} [Unarmed] ]] %NEWLINE%%NEWLINE%**Unarmed**}}|@{AltUnarmedName},[[d20+@{selected|AltUnarmedHit}+@{selected|AltUnarmedHitBonus}@{PhysMod}+?{Modifier|0} [@{AltUnarmedName}] ]] %NEWLINE%%NEWLINE%**@{AltUnarmedName}** %NEWLINE%%NEWLINE%**Chi Drain:** $[[1.computed]]%NEWLINE%%NEWLINE%**Chi Remaining:** $[[2.computed]]}}!setattr --name @{selected|character_name} --Chi|[[@{selected|Chi}[[-1*1d6]]]]!!!|@{Weapon1Name}, [[d20+@{selected|Weapon1Hit}+@{selected|Weapon1HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon1Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon1Name}**}}|@{Weapon2Name}, [[d20+@{selected|Weapon2Hit}+@{selected|Weapon2HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon2Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon2Name}**}}|@{Weapon3Name}, [[d20+@{selected|Weapon3Hit}+@{selected|Weapon3HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon3Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon3Name}**}}|@{Weapon4Name}, [[d20+@{selected|Weapon4Hit}+@{selected|Weapon4HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon4Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon4Name}**}}|@{Weapon5Name}, [[d20+@{selected|Weapon5Hit}+@{selected|Weapon5HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon5Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon5Name}**}}|@{Weapon6Name}, [[d20+@{selected|Weapon6Hit}+@{selected|Weapon6HitBonus}@{PhysMod}+?{Modifier|0} [@{Weapon6Name}_Attack] ]] %NEWLINE%%NEWLINE%**@{Weapon6Name}**}}} {{supplementary=**Actions:** ?{Actions|1}}} What broke:  -[[1d6]] didn't make the "-" sign pop visually. So I put it inside [[-1d6]] Problem is: that is not interpreted the way humans would interpret it...so it broke the d6 roll.  Fix is: [[-1*1d6]] And that is tested and works. 
1771366346
Rogue
Pro
Marketplace Creator
You are awesome! Thanks very much Gauss, I see you in here helping everyone you hero!