# Talk:Macros

### From Roll20 Wiki

Hey, how can I set @{selected|bar1}?

Basically I want to roll 2d6 and add the value to bar1, etc. Any help would be awesome!

## AC vs AC_no_armour—use best inside macro

playing as a monk or barbarian in 5e it is advantageous in almost all situations to be unarmored. which leaves the AC stat at 0 or really low. this is not accurate as i understand the rules—base AC naked is always 10+dex mod, wearing armor replaces this with the armor's base AC and allows for or not the +dex mod. so even when no armor, or even clothing, is worn the AC in both fields should be 10+dex mod.

this is not the primary concern i have however. while i understand the utility in being able to store distinct values for armored and unarmored AC, the fact is the player will almost always be wearing or not wearing armor to gain the highest AC. as such a dice macro should be able to just specify @{target|AC} and the result is the higher of the two values between "AC" and "AC_no_armour". if there is already a way to do this please let me know.

i know that it is possible to use inline rolls to evaluate {@{target|AC},@{target|AC_no_armour}}kh1 to get the highest one of the two values, but this does not work inside an inline roll (example: [[{1d20+@{selected|str_mod}}>{@{target|AC},@{target|AC_no_armour}}kh1]] and [[{1d20+@{selected|str_mod}}>[[{@{target|AC},@{target|AC_no_armour}}kh1]]]] do not work). it would work as /roll {1d20+@{selected|str_mod}}>[[{@{target|AC},@{target|AC_no_armour}}kh1]], but this does not work inside of a roll template.

i was wanting to do this to allow players an easy way to attack npcs without giving them any information about the npcs's AC. as the above examples would return a 1 or 0 depending on successful hit or failure. but i like the collapsed format of the inline rolls over the /roll command.

It may or may not help you hide the details of an inline roll from hover peeking. By Doubling the enclosure bracket.

example...

/r 1d20+10 ----regular [[1d20+10]] ----inline Hoverable [[[[1d20+10]]]] ----inline hover shows only the final result

That would hide any actual details about the roll. As for evaluation try "floor" to setup your macro. plug in your own VARs @{target|AC}, @{target|AC_no_armour}, ect...

Copyed from https://wiki.roll20.net/Useful_Macros

Conditional Statements Using the multiplicative properties of 0(absorption) and 1(identity) you can write conditional statements for integer values(and to some extent floating point values too)

An example of this is the formula "if x greater than or equal to A, then T; else F," where T and F are some values.

This can be written as a macro with

[[-1*floor((A-x-0.1)/(abs(A-x-0.1)+0.001))*T - floor((x+0.1-A)/(abs(x+0.1-A)+0.001))*F]]

Similarly, "x greater than A, then T; else F" is written

[[-1*floor((A-x+0.1)/(abs(A-x+0.1)+0.001))*T - floor((x-0.1-A)/(abs(x-0.1-A)+0.001))*F]]

"x equals A" is simpler, and works when x is a dice roll, but not when F is a dice roll

[[F + round((T-F)/(10*(x-A+.1)))]]

Now for some identities: "x less than A" is the inverse of "x greater than or equal to A," so the conditional can be written as "x greater than or equal to A, then F; else T" using the formulas above. Similarly with "x less than or equal to A" and "x greater than A," as well as with "x not equal to A" and "x equal to A."

## Linking macros to Handouts: Is this possible?

Hey, just wanted to know if it is possible to link a macro to a handout? For example, in our campaign we have a magic item that gets passed around a lot from character to character; I have a Handout created for this character and have listed the players who can use it in the edit option but would like to be able to add a macro that they can use for their macro bar/token option so they can just click on it and bring up the macro.