May 3

Roll20 macros

Better automation through macros

So I’ve spent the best part of a day unlearning some bad habits when I set up the Roll20 sheets for my players.  I wish I’d spent some more time getting to grips with the documentation before I set down to create but I realise the campaign was based upon one of my first fumbling attempts at getting Roll20 to behave how I wanted.

Why Macros?

A macro is a statement that tells Roll20 to execute a string and in my case I had defined attack macros, dodge macros and damage macros.  What I forgot is that you can create a central pool of macros for all to use rather than creating them individually in each characters journal.  When I set the journals up I used the former method rather then the latter.  The downside was that as I read the documentation I learned more about how to write an effective macro and I was faced with the realisation that I would have to change it for each character that had a journal entry.

Why Change?

I changed because my players deserved better than me saying “Ah, I haven’t set that macro up yet on that character” and since I had some free time this weekend I did just that.  I scrapped the individual macros and harnessing the power of the language I re-wrote the macros while taking the time to improve them into something more functional.


So I present to you an example macro from the library that my players have access to, a simple ranged combat macro:

/em @{selected|token_name} fires my handgun!
/roll 1d10 +@{selected|Dexterity} + @{selected|Guns (Handgun)}  
+ ?{Additional Attack Bonus/Penalty?|0}
!ammo Pistol ammo

I also created them as token specific which means that you have to have a token highlighted before it will correctly execute.

The first line has the token announce the name of the token and what its doing.  The second line rolls a d10, adds the values of Dexterity and the handgun skill together before popping up a dialogue box asking if there are any other miscellaneous modifiers to add to the roll; say a situational modifier for someone that has been aiming long enough to obtain a bonus or if they are using a scope.

The final line calls a script which decreases the value of an attribute called Pistol ammo by one.  This way the player can see how much ammo they are going through as I used one of Roll20s radial buttons for this task.

There are more things to be done, but I hope that my players will see the benefits of a well written macro.