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 .
×
Create a free account

Macros with variables

From the help tutorial menu: Using a variable with a Macro If you'd like to use a variable modifier with your macro roll, simply end the macro command with the modifier, and then specify it when calling your macro Example If I want a macro for 1d20+x ( where x is my variable value ) I could create the following macro: #d20   /roll 1d20+ then, when running the macro, type  #d20 4  to get  /roll 1d20+4 I made a macro that looks like this:  /desc The fierce ogre lunges, spear in hand! /gmroll d20+14+  /gmroll d8+13 /gmroll d20+9+ /gmroll d8+13 I was hoping that the macro would perform as normal unless I added in a number at the end when starting it. Ie it would treat the open + as a zero.  Instead I find that the macro disregards all math in the line with the open + and just rolls the dice as requested.  Is there any way to make it treat the open + as a zero unless otherwise specified? I was hoping to use the variable to enter ad-hoc bonuses like flanking or short-duration buff spells without adding them to the attack macro.
First, and easiest answer: use parenthesis ( )- it counts that as a 0 space, I pretty sure, and you can put a variable in it. I'm pretty sure you can still add/subtract to that using "#d20 +4" in the chat box as well, without the open "+" in the macro (I'd have to test to be sure). A little more in depth, and I'm sure someone's got a better way to do it, but this is what I use the Attributes for to create Abilities that I can use as macros and adjust on the fly. For your ogre in question, I'd have Attributes: BAB, Str, etc. I'd use the two columns for current and normal max-- allowing me to open the journal and put a -1 on BAB if the party BANE's the ogre, for instance. Then, in Abilities, I create macros that use these attributes. Using your example, I'd set it up something like this: /gmroll d20+(@BAB)+(@Str) same for damage for now and /gmroll d20+(@BAB)+(@Str)-(5)[Second Attack] The parenthesis should work fine. The abilities macros let me set these up for my monsters in the journal and put them on the macro bar based on encounters I need them for... EDIT: I tested the "#Macro +X" in chat and it works fine-- your original strings will work without the plus-signs, but not sure how it will work with multiple rolls in a single macro.
1366525597
Gauss
Forum Champion
Eivind, the problem is that when you type #Macro +X the +X is added to the very last line of the macro. - Gauss
Ah, that explains it! Thanks for your replies. I'm starting to experiment with attribute macros to solve it instead, wondering if that'll solve it. Currently I'm rolling:  /gmroll d20+14+Game Master: To Hit Bonus 1 +Game Master: To Hit Penalty 1  /gmroll d8+13+Game Master: Damage Bonus 1 +Game Master: Damage Penalty 1 /gmroll d20+9+Game Master: To Hit Bonus 1 +Game Master: To Hit Penalty 1 /gmroll d8+13+Game Master: Damage Bonus 1 +Game Master: Damage Penalty 1 A little messy, but it works. Bonus points because I don't have to manually remember each buff and penalty and since I haven't gotten around to killing the bard yet the debuff list is starting to get out of control...