# In Roll20, how to program a macro that mimics the built-in attack function?

In R20, when you make an attack roll using the built-in char sheet for 5E, it outputs 2 results (with modifiers and everything) in a single line. I'd like to do this with a Macro, so that I can access this functionality quickly through the Toolbar (I read the Macro section and the Dice reference from the R20 wiki, and no luck).

Alternatively, if there's a way to add the Attack and damage buttons from the character sheet to the Macro toolbar, that would be even easier.

If you roll from the character sheet, you should be able to hit the 'up' key in the chat box to see what the character sheet macro actually entered automatically for you (hitting 'up' in the chatbox refills the chatbox with the previous submission). You can copy and paste that into a custom-made macro to create a macro with the same effect, and can then check the option to put it in your macro bar.

For example, after rolling a melee weapon attack and hitting up, I see:

/em uses @{Eausreph Sliicoe|meleeweaponname1} to attack

[[1d20 + @{Eausreph Sliicoe|meleetohit1} [To Hit] + @{Eausreph Sliicoe|global_melee_attack_bonus} [Active Melee Attack Bonus] ]] | [[1d20 + @{Eausreph Sliicoe|meleetohit1} [To Hit] + @{Eausreph Sliicoe|global_melee_attack_bonus} [Active Melee Attack Bonus] ]] vs AC

When I put that in a macro, I get the same output as hitting the character sheet button.

In addition to that workaround, due to a roll20 update since the original question, you can now just drag the button onto the macro bar and it will create a macro for that roll for you.

• You, sir/ma'am, are divine. This was bugging me to no end, and it didn't occur to me to give this a shot. – Khashir Sep 7 '14 at 19:11
• I plan to offer a small bounty, jut cause this is so damn useful. Thank you. – Khashir Sep 7 '14 at 19:14
• To be entirely honest, I went on Roll20 to take a look and hit up by accident after hitting the macro. This was not my initial thought for a solution :-P (Man, there are a LOT of little hidden statistics/attributes that go into that macro- hovering over the dice roll shows how many different stats it pulls from. I was originally trying to figure out what they all were.) – CTWind Sep 7 '14 at 19:16
• Jajajaja, hey, it's a windfall :) – Khashir Sep 7 '14 at 19:20
• +1 for the update on what's going on with the dev server. Glad you're keeping up with your answer! (As a Mentor, I can say it's a little buggy at the moment, but it seems this next update Riley's pretty much pulling in a bunch of things from the suggestions forum. There are several things on the dev server right now where Riley has basically said, "Well I added this, this, and this today...") – Brian S Nov 7 '14 at 15:16

Skimming through some Roll20 questions just to see what there was I saw this one. And I have a different answer that might be based on new features/information. This was something I struggled with myself and figured out. I'm working with Pathfinder, but a quick search shows that this applies to D&D 5--and other--sheets as well.

# For Repeating Attacks/Abilities

1. Find these RowID fields:
• These fields exist for virtually all special abilities, attacks, spells, and such. Skills, core attributes, etc. are handled slightly differently. These are covered below.
• If you can't get them listed in the built-in sheet, you can use Firefox or Chrome's developer tools, looking for something with the sort of name or identifier of "row id" or "row identification" and a value that looks similar to that gobble-de-gook starting with a hyphen. There may be a setting that hides these values, but I can't seem to find it at the moment.
2. Hover over the black "make roll" button next to the desired ability. The tooltip will show the base macro to use. Replace the \$X portion with the row ID and selected with the character's name.
• For example, my character Ruhk has this macro for firing a crossbow: @{Ruhk|repeating_weapon_-lalzh495fudfrdrjpue_attack-roll}, matching the row ID from the screenshot.
3. Test it. If you bungled something, it won't work right. If you didn't, you'll get a nice macro result, same as if you clicked the button. No more giant macros of doom to do what someone else already did.

# For Core Attributes, Saves, Skills, etc.

1. Remember the black "make roll" button? Find that button next to the desired attribute to roll
2. Replace selected with the character's name.
• For example, for my character Ruhk, I use %{Ruhk|Roll-for-initiative} &{tracker} for initiative (oh hey, the &{tracker} macro tag for adding your initiative to the initiative tracker! Of course, Ruhk's token still needs to be selected...1) and for Perception it's %{Ruhk|Perception-check}. Will Save? %{Ruhk|Will-Save}
• These "key words" are all listed in this answer over on another question, but are discover-able just by hovering over the associated roll button.

# Other values

This works for other values, like HP as well. The tricky bit here is that the tooltip does not have selected in it! No worries, add the character's name, and then a pipe.

• For example for my character Ruhk's HP and Max HP I would use @{Ruhk|HP} @{Ruhk|HP|Max} respectively.

# Caviats

Yes, there are some downsides to this!

You cannot encode these sorts of macros inside other macros. The nested macro system explicitly requires that the nested macro resolve to its value when the parent macro executes. I tried really super hard to create a macro that asked me what skill I wanted to roll, then passed the result (as a string) to the @{selected|Skill-<value>} macro, but that will not work. It throws errors before the dropdown even displays.

No, not even if you try and trick the system by setting up Skill-A, Skill-B, Skill-C macros that point back to the sheet. Each macro in a nested macro is parsed to its value before the macro is executed. As such, you cannot reference character sheets in this manner. See this section of the documentation.

To reiterate an important point: do not subject any @{Attribute}, %{Ability} or #Macro c̲a̲l̲l̲s to any character replacements.

1 Did you bungle having your token selected? Select your token, put [[?{Initiative?|10} &{tracker}]] in the chat (or as a separate macro). Specify your own value. Or you can select your token, roll again, and then double-click the value in the tracker and change it. Did you know you could do that?

Fx macros go above your action macro.

The Beam fx macro will shoot a beam from your character token toward a target token. For this macro do not change the effect type, only change the color.

/fx beam-acid @{selected|token_id} @{target|token_id} \\n &{template:foo}


The magic on a target other than your token.

/fx beam-acid @{target|token_id} @{target|token_id} \\n &{template:foo}


The Cast magic on self use when you desire for the Fx to come from your characters, token.

/fx beam-acid


​Special effects types, the first word after /fx, will affect the animation. In /fx BEAM-acid, BEAM is the type and can be changed to the following types for other effects: bomb, breath, bubbling, burn, burst, explosion, glow, missile, nova, splatter.

​Special effect Color will change the color of the desired effects. In /fx beam-ACID, ACID is the color and can be changed to the following types: bloom, charm, death, fire, frost, holy, magic, slime, smoke, water.

These are the only two words that need to be changed, otherwise copy and paste the desired effect above the action.

• I don't understand your explanation for the third example at all. Can you rewrite it to be grammatical? – user17995 Feb 9 '17 at 19:58