Macro Basics The usage of macros in Roll20 can make things a lot simpler for yourself, your DM and your party. This thread aims to introduce people to the usage of macros and offer some tips & tricks for more advanced macro usage. Additional information can also be found on the wiki and in this Reddit post. To start using macros, you can either use the Attributes & Abilities section within your character sheet, or you can go to the Settings section (next to Decks & Tables and the Jukebox). To start creating a macro, simply click on Add. As an example, the most simple macro is: Code: /roll 1d20 The sections below will treat the additional features you can implement in your macros Roll Templates Various roll templates are available. Two example templates can be seen below and additional templates can be found here. You can use the template by putting the code shown below somewhere inside your macro. Code: &{template:default} Code: &{template:5eDefault} Fields As can be seen in the two images shown above, you can add numerous field with an output to them to the macro. The syntax is: Code: {{Fieldname=Text}} For example: Code: &{template:5eDefault} {{Attack=[[1d20]]}} @{Character name|classactioncustom1skill} You can see here that the /roll has been removed, and that the roll itself has been put in double square brackets. These brackets cause Roll20 to actually perform the roll and add the yellow background you see in the image above. The @{Name|classactioncustom1skill} is needed for the macro to work correctly. Advanced Rolls The rolls shown so far are pretty basic. However, they can be made a lot more complex and advanced. If you want to change the definition of a critical roll or a critical fail, you can change the roll into the following: Code: &{template:5eDefault} {{Attack=[[1d20cs>20cf<1]]}} @{Character name|classactioncustom1skill} Here you can change the second 20 and the 1 to whatever you want to be the critical roll and critical fail respectively. If you want to use inputs from your character sheet, things get a bit tricky. First, you'll need to find the reference to the field you want. For the D&D 5e template, you can find a list of field references here. To see an example of a damage roll that uses the weapon specific ranged damage bonus and the global ranged damage bonus, you can see the code shown below: Code: &{template:5eDefault} {{Damage=[[1d10+[[@{Character name|rangeddmgbonus1}]] + [[(@{Character name|global_ranged_damage_bonus})]] ]] Piercing}} @{Character name|classactioncustom1skill} You can see here that the syntax is @{Name|Attribute}. If you don't want to change the name every time you make a new character, you can also use @{selected|Attribute}. However, you'll need to select the token in that case. Title & Subtitles To add a (sub)title to the banner shown in your output, you can use the code shown below as a template. Code: &{template:5eDefault} {{title=Pistol Shot}} {{subheader=@{Character name|character_name}}} {{subheaderright=Ranged attack}} Color Controls For the 5eDefault template, you can change the color of the banner shown in the output by adding a bit of code to your macro. A list of the code and the corresponding color can be found below: {{weapon=1}} Green {{spell=1}} Purple {{ability=1}} Teal {{save=1}} Red {{deathsave=1}} Maroon Drop-down menus and Input Requests Roll20 also allows for the use of drop-down menus and various input requests. An example of a simple input request can be seen in the code below Code: &{template:5eDefault} {{Fieldname=[[1d20 + ?{Modifier|0}]]}} @{Character name|classactioncustom1skill} This will prompt the user to input a modifier, which will then be added to the roll. To use drop-down menus, you should use the following: Code: ?{Name of Query|Label 1,value1|Label 2,value2} which could become: Code: &{template:5eDefault} {{Test=[[(?{Roll?|1,5|2,10}*2)d4]]}} @{Character name|classactioncustom1skill} This will roll either 10 or 20 d4s depending on the user input. While you can use two separate drop-downs with a different query name to change multiple fields, you'll need to be a bit more crafty if you want to do it with only one drop-down menu. The reason is, that you can not have the same drop-down twice with a different output. So, this is not possible: Code: &{template:5eDefault} {{Test=[[(?{Roll?|1,5|2,10})d4]]} {{Test2=[[(?{Roll?|1,20|2,40})d4]]} @{Character name|classactioncustom1skill} To work around this, you'll need to make sure that a drop-down only outputs the same value. In the example above, you could work around this by noticing that the output for the second field is four times as large as the one in the first field. Thus, you could write this as: Code: &{template:5eDefault} {{Test=[[(?{Roll?|1,5|2,10})d4]]} {{Test2=[[(?{Roll?|1,5|2,10}*4)d4]]} @{Character name|classactioncustom1skill} Note here that the drop-down now outputs the same value, but that the result of it is simply multiplied by four. If this is not possible in your case, there is another workaround, but it is a bit of a pain. If you'd like to know more, I suggest reading this post first. It boils down to doing it as follows: First, write the output of the drop-down menu as you want it. In this example, we'll be outputting two fields depending on the drop-down selection. Thus, the basic field will be: Code: &{template:5eDefault} ?{Test|Test1,{{Field1=Bla}}{{Field2=Bla2}}|Test2,{{Field3=Bla3}}{{Field4=Bla4}}} @{Character name|classactioncustom1skill} Next, replace the following in your code: Find: "{{" Replace with {{ Find: "}}" Replace with }} Find: "," Replace with , The example shown above thus becomes: Code: &{template:5eDefault} ?{Test|Test1,{{Field1=Bla}}{{Field2=Bla2}}|Test2,{{Field3=Bla3}}{{Field4=Bla4}}} @{Character name|classactioncustom1skill} This will output the fields 1 and 2, or 3 and 4 depending which drop-down you choose. As said in the link, it's wise to do this as a Journal Ability instead of a macro in the Settings section. Otherwise you'll have to re-edit the {{ and }} into {{ and }} every time you want to edit the macro.
Macro Examples As a source of inspiration, here's a list of the macros that I've created so far. If you're aiming to make a macro yourself, have a look at them and see if any of them sort of do what you're looking for. Of course, don't forget the change the @{name|attribute} to either your character name or "selected". Spoiler: Macros Spoiler: Basic Initiative Macro Code: &{template:5eDefault} {{title=Initiative}} {{subheader=@{selected|token_name}}} {{Initiative=[[1d20+ @{Erevan Rayport|Initiative} +@{selected|dexterity_mod} &{tracker} ]] }} @{selected|classactionrangedweapon} Spoiler: Tinker's Tools Check using a drop-down menu Code: &{template:5eDefault} {{character_name=@{Erevan Rayport|character_name}}} {{title=Tinker's Tools Check}} {{subheader=@{Erevan Rayport|character_name}}} {{subheaderright=Ability Check}} {{ability=1}} {{DC=[[8+?{Weapon?|Pistol,1|Musket, 2|Pepperbox, 2|Scattergun, 3|Bad News, 3|Hand Mortar, 3}]]}} {{Result =[[1d20+ 1+[[@{Erevan Rayport|PB}]]+[[@{Erevan Rayport|dexterity_mod}]] ]] | [[1d20+1+ [[@{Erevan Rayport|PB}]]+[[@{Erevan Rayport|dexterity_mod}]]]]}} @{Erevan Rayport|classactioncustom1skill} Spoiler: Pistol shot with Sharpshooter & Deadeye Shot option Code: &{template:5eDefault} {{character_name=@{Erevan Rayport|character_name}}} {{title=Pistol Shot}} {{subheader=@{Erevan Rayport|character_name}}} {{subheaderright=Ranged attack}} {{?{Deadeye Shot?|No,emote=|Yes,emote=spends 1 grit point to get an advantage on the attack roll}}}{{weapon=1}} {{Attack=[[1d20cs>20cf<1+ [[@{Erevan Rayport|rangedtohit1}]] + [[@{Erevan Rayport|global_ranged_attack_bonus}]] -5*?{Sharpshooter?|Yes,1|No,0}]] | [[ 1d20cs>20cf<1+ [[@{Erevan Rayport|rangedtohit1}]] + [[@{Erevan Rayport|global_ranged_attack_bonus}]] -5*?{Sharpshooter?|Yes,1|No,0}]]}} {{Damage=[[1d10+[[?{Sharpshooter?|Yes,1|No,0}*10]]+[[@{Erevan Rayport|rangeddmgbonus1}]] + [[(@{Erevan Rayport|global_ranged_damage_bonus})]] ]] Piercing}} {{If Crit=+ [[@{Erevan Rayport|rangedcritdmg1}]] dmg & +1 grit}} @{Erevan Rayport|classactioncustom1skill} Spoiler: Pistol trick shot with Sharpshooter Code: &{template:5eDefault} {{character_name=@{Erevan Rayport|character_name}}} {{title=Pistol Trick Shot}} {{subheader=@{Erevan Rayport|character_name}}} {{subheaderright=Ranged attack}} {{weapon=Pistol}} {{Attack =[[ 1d20cs>20cf<1 + [[@{Erevan Rayport|rangedtohit1}]] + [[@{Erevan Rayport|global_ranged_attack_bonus}]] - 5*?{Sharpshooter?|Yes,1|No,0}]] | [[ 1d20cs>20cf<1+ [[@{Erevan Rayport|rangedtohit1}]] + [[@{Erevan Rayport|global_ranged_attack_bonus}]] -5*?{Sharpshooter?|Yes,1|No,0} ]]}} {{Damage =[[1d10+ [[@{Erevan Rayport|rangeddmgbonus1}]] + [[(@{Erevan Rayport|global_ranged_damage_bonus})]] + 10*?{Sharpshooter?|Yes,1|No,0}]] Piercing}} {{If Crit =+ [[@{Erevan Rayport|rangedcritdmg1}]] dmg & +1 grit}} @{Erevan Rayport|classactionrangedweapon}} @{Erevan Rayport|ro_ranged1} @{Erevan Rayport|classactionrangedweapon}{{ =----------On Hit----------}} ?{Body Part?|Head, {{emote=Erevan spends 1 grit point and aims for the target's head }}{{ Save=DC [[8+[[@{Erevan Rayport|dexterity_mod}]]+[[@{Erevan Rayport|PB}]] ]] CON }} {{Save Fail=Disadv. on attacks until end of target's next turn}}|Arms,{{emote=spends 1 grit point and aims for the target's arms }}{{ Save=DC [[8+[[@{Erevan Rayport|dexterity_mod}]]+[[@{Erevan Rayport|PB}]] ]] STR}} {{ Save Fail = Drop 1 held item of player's choice }}|Torso,{{emote=spends 1 grit point and aims for the target's torso }} {{ Effect=Pushed 10ft away from player }}|Legs/Wings,{{emote=spends 1 grit point and aims for the target's legs or wings}} {{ Save=DC [[8+[[@{Erevan Rayport|dexterity_mod}]]+[[@{Erevan Rayport|PB}]] ]] STR }} {{ Save Fail=Knocked prone }} } @{Erevan Rayport|classactioncustom1skill} Spoiler: Violent Pistol Shot with Sharpshooter Code: &{template:5eDefault} {{character_name=@{Erevan Rayport|character_name}}} {{title=Violent Pistol Shot}} {{subheader=@{Erevan Rayport|character_name}}} {{subheaderright=Ranged attack}} {{weapon=1}}{{emote=spends ?{Spent grit|1} grit point(s) to push his weapon past its intended limit, at the peril of damaging it}} {{Attack =[[ 1d20cs>20cf<[[1+2*?{Spent grit|1}]] + [[@{Erevan Rayport|rangedtohit1}]] + [[@{Erevan Rayport|global_ranged_attack_bonus}]] - 5*?{Sharpshooter?|Yes,1|No,0} ]] | [[ 1d20cs>20cf<[[1+2*?{Spent grit|1}]]+ [[@{Erevan Rayport|rangedtohit1}]] + [[@{Erevan Rayport|global_ranged_attack_bonus}]] -5*?{Sharpshooter?|Yes,1|No,0} ]]}} {{Damage =[[[[?{Spent grit|1}+1]]d10+ [[@{Erevan Rayport|rangeddmgbonus1}]] + [[(@{Erevan Rayport|global_ranged_damage_bonus})]] + 10*?{Sharpshooter?|Yes,1|No,0}]] Piercing}} {{If Crit =+ [[@{Erevan Rayport|rangedcritdmg1}]] dmg & +1 grit}} @{Erevan Rayport|classactioncustom1skill} Of course, if you've made any neat macros yourself, don't hesitate to post them here as well and if you need help, feel free to ask
Awesome! I use Roll20 a lot, and I have used a few macros, but I'm sure I will find this extremely useful :3 Thanks!
No problem, glad to read you find it useful If you know of anything that I should add, just tell me. Also, if you've got any macros you think would be useful for others, don't hesitate to post them here (can be for whatever RPG)