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

Showing Green for a Hit and Showing Red for a Miss

As title says, basically, writing a macro that compares your attack roll to the targets AC and will show green if you make the attack roll, or red if you miss. I'm a complete noob when it comes to script writing, but, it doesn't seem I can reference "@{target|NPCarmorclass}" more than once, without the macro bugging out. Once entered, it'll ask me to target a token again, after already designating a token, but won't let me select the token again. Here's my syntax... [[d20cs>[[@{target|NPCarmorclass}-?{modifier|0}]]cf<[[@{target|NPCarmorclass}-?{modifier|0}-1]]]] vs AC Any thoughts would be appreciated, thank you!
1545205202

Edited 1545205244
GiGs
Pro
Sheet Author
API Scripter
I copied your macro, and it worked for me. One problem I did notice is that if the modifier is negative, it doesnt work properly. If you do want to attack multiple people in the same macro, you can use this syntax: @{target|foe|NPCarmorclass} Basically each time you use @target it thinks you are targeting a new opponent. But you can add a middle parameter, to show you mean to attack the same foe. So if you had this macro: [[d20cs>[[@{target|foe|NPCarmorclass}-?{modifier|0}]]cf<[[@{target|foe|NPCarmorclass}-?{modifier}-1]]]] vs AC It will assume the second target is for the same target as the first, and you should be prompted only once. This is handy because you can also do this: [[d20cs>[[@{target|foe1|NPCarmorclass}-?{modifier|0}]]cf<[[@{target|foe1|NPCarmorclass}-?{modifier}-1]]]] vs AC [[d20cs>[[@{target|foe2|NPCarmorclass}-?{modifier|0}]]cf<[[@{target|foe2|NPCarmorclass}-?{modifier}-1]]]] vs AC If you have both the above lines in the same macro, you get to make two attacks, against different targets (or you could select the first target again on your second). You can use any word in place of foe, just as long as you use the same label for calls to the same token, and different labels if calling multiple tokens.  Also note that calling the modifier more than once doesnt need the |0 part after the first call.  I'm not sure why it is failing for you, all the above examples, and you original macro, worked for me. As long as the modifier was 0 or above, not sure how to fix the problem with negative modifiers.
Ah, okay! You're the man, thank you!
1545232132
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
GiGs, I had no idea about that middle parameter! Is that documented somewhere?
1545255266
GiGs
Pro
Sheet Author
API Scripter
It is mentioned in the wiki on the macros page here  but it's easy to miss.
1545256018

Edited 1545256028
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks! If I read that, I've completely forgotten it. I hate finding cool solutions. Now I have to go look for a problem to fit it.