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

Can I make a macro with an if condition?

I have a character that has a feat that makes a roll of 2-8 a 9 for certain skills. I was messing around with macros earlier to see if I could make this happen but just ended up with a mess. Is it possible to make a macro that will change a roll's value if it rolls a certain number?
Currently if/then statements aren't supported by macros, however through the API console for mentors you can write it up :(
As a workaround, you can use a rollable table. The table would look like: Value/Weight 1/1 9/8 10/1 11/1 . . . 20/1
Alright. I will see if I can work it out with a table first. Thank you all.
Does anyone know if some basic logic, if then, and, or statements would ever feature in macros? Are the developers looking at this. Seems to be a top request by the community. (or maybe it's just me because I desperatley want this feature.)
Sheet Author
API Scripter
I don't believe the devs have said "no, we're not going to make conditional logic in macros," but they have said they're wary of turning the macro system into a full-blown language. Decision trees pushes macros towards such a status. There's a common workaround that helps in some cases: multiplying a value by a roll query. If you enter 1 in the query, the value is multiplied by 1 and functions. If you enter 0 in the query, the value is multiplied by 0 and does not function. (You could use other numbers as well depending on your need, but 0/1 is the most common.) For example, a macro for D&D Next allowing for regular rolls vs. rolls with Advantage could be expressed as [[{d20+d20*?{Advantage|0}}kh1]]. If you leave the popup at 0, the roll becomes "d20". If you put a 1 into the query, the roll becomes "2d20kh1". More complicated logic is limited to the API, which is one of the draws for Mentor status.
Riley D.
Roll20 Team
Chris A. said: Does anyone know if some basic logic, if then, and, or statements would ever feature in macros? Are the developers looking at this. Seems to be a top request by the community. (or maybe it's just me because I desperatley want this feature.) One of the things we're doing with Rugged Reroll is examining the relationship between macros, the dice engine, abilities, attributes, and the API. Those discussions are still ongoing, so nothing is set in stone yet. Our current thinking is that the API is for automation, complicated ability chains, customizing the game to closely fit a ruleset, etc. Macros are "shortcuts" to the dice engine. And the dice engine is about making rolls, not automating things. We have expanded macros/dice rolls to allow you to pull in additional information (such as with roll queries and the selected token flags), but I'm not sure how far we'll end up walking down that path. Right now, if/then logic is not on the roadmap for macros.
Thanks for the response Riley. That context makes a lot of sense and understand your position. However, there is a bit of a grey area between rolls and automation. They key one that springs to mind is to roll extra dmg on a critical hit because my players have the 'ax of awesome' What I'm keen on is to have something like, Roll 1d20+5 dmg + (if roll = 20 then roll 1d6 extra dmg). Not quite at API level of complexity but would still make a huge difference in speeding up the game and helping my players.
Sheet Author
API Scripter
Add variables, loops, and recursion to the dice system. Suddenly it's Turing-complete! =) (Okay, it'd still be pretty difficult to write a program using the dice roller with a minimally Turing-complete system, but hey...)

Edited 1382664767
I do a lot of wilderness adventures using oe or S&W. Encounter tables are set up with one to determine the type followed by another roll on the appropriate table for the specific monster of that type in the appropriate terrain. As a DM, being able to use "if, then" modifier to direct another roll to the indicated table would speed play and increase enjoyment for my players.
KS Backer
@ Chris A, I think the multiplication trick noted above would work for criticals, which are presumably triggered by the result of a previous skill roll. So, assuming the player rolling damage knows whether or not they've scored a critical hit, you could make the macro: /r 1d20+5+1d6*?{Set to 1 if Critical Hit}|0}
@Spyke, that's a good idea but most of our macros are built to roll the hit and then dmg all in the one macro. It's super fast and really helps move the game along. The bits in bold we currently have to do manual. I'd love the ability to simply code those in factors based on the various conditions. The idea is to allow the players to focus on the roll playing, the game, the discussion rather than spending lots of time working out the math or doing extra rolls. I smite you! /r 1d20 + @{HLevel_Mod} + @{STR_Mod} + @{Weapon_Att_Mod} + @{Weapon_Prof} vs AC; {+1 if bloodied} On hit; /r 2d6+@{STR_Mod}+@{Weapon_Dmg_Mod}+@{Astral_Fire} dmg; (+1d6 on critical) An ally gains +@{STR_Mod} to melee attack rolls against target until end of my turn.
Well, you could set up your macro to have a prompt for if there's any special condition modifiers. You'd have to hit enter two more times if there's nothing to change, so it doesn't really slow anything down on a regular attack, and if there is a special condition, you have a chance to put it in.

Edited 1387354584
Alex L.
Sheet Author
If you had a way to store the roll you could do something along the lines of: /r [some damage roll here] + (floor([stored roll] / (20 + [some mods])) * ([critical dice and stuff]) Sadly I cant see how you would store the roll at the moment.