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

IF/ELSE statements in 3.5 character sheet Macros?

Is there syntax for IF statements?  What I am trying to make for my players is a convenient macro that allows them to select their target, input any necessary modifiers, output damage if they hit, and output "miss" otherwise. I would like to pull the target's AC from its sheet using the @{target} syntax and compare it to the players attack roll and determine if they hit, but I can't find syntax for IF/ELSE statements anywhere on the wiki? Does it just not exist or am I missing something? 
1475185514
Andrew C
Marketplace Creator
Macros don't provide IF-THEN-ELSE so the Character sheets won't either. If you add the AC to one of the Bars, you can do a "manual" comparison by having an @{target|barN}. [[1d20+stuff]] vs @{target|barN} in the Template
1475194208

Edited 1475194241
Tetsuo
Forum Champion
There's an API script called power cards that allows some if then functionality, though it requires a PRO level subscription. 
<a href="https://wiki.roll20.net/Useful_Macros#Conditional_" rel="nofollow">https://wiki.roll20.net/Useful_Macros#Conditional_</a>... I found this on the wiki, but I'm having trouble wrapping my head around it. My coding knowledge is very minimal and entry level but I think I could figure this out if I had someone explain it to me a little better.
Theelix said: <a href="https://wiki.roll20.net/Useful_Macros#Conditional_" rel="nofollow">https://wiki.roll20.net/Useful_Macros#Conditional_</a>... I found this on the wiki, but I'm having trouble wrapping my head around it. My coding knowledge is very minimal and entry level but I think I could figure this out if I had someone explain it to me a little better. Yah I was looking at that the other day and it has to be literally the worst syntax I've even seen for a scripting language. I want to add conditional statements for some of my rollable tables, but that just makes my head hurt.
1475264730

Edited 1475264923
I added "Math Only" to the title of that section to clarify that it's simply a few math tricks: Conditional Statements (Math Only) Roll Templates can be coded to include Helper Functions (e.g. rollWasCrit() ), which allow for information to be conditonally displayed in certain circumstances. Some Character Sheets on the dropdown (available to all users) include Roll Templates with Helper Functions, which can be taken advantage of within macros. Otherwise, Pro users can write and implement their own Roll Templates within games that they create. Some other (non-API) solutions for conditional evaluation do exist, some of which I like to call " budget conditional statements ", which are also outlined here .
Thanks for the clarification Silvyre. I guess I read over that. I got close to implementing it in the normal 3.5 attack template macro to where it would roll the regular attack macro as normal and then out put a 1 if they hit and a 0 if they missed by using the @{target|armorclass} and @{selected|weapon1attackcalc} in place of x and A. The only issue I'm having now is that when I call @{selected|wapon1attackcalc} it rolls a seperate result than the result that was rolled in the template attack macro. If there was some way to pull that same result from the template I would have everything I needed but I cant find the name of that variable.This is what I have so far. @{selected|character_name} attacks @{target|character_name} &{template:DnD35Attack} {{pcflag=true}} {{name=@{selected|character_name}}} {{subtags=attacks with a @{selected|weapon1name} }} {{attack1=A1: [[ @{selected|weapon1attackcalc} ]] }} {{critconfirm1=Crit?: [[ @{selected|weapon1attackcalc} ]] }} {{fumbleroll=Fumble: [[ d20 ]] }} {{damage1=D1: [[ @{selected|weapon1damage} ]] }} {{critdmg1= [[ @{selected|weapon1crit} ]] }} {{fullattackflag= [[ ?{Full Attack?|No, 0d1|Yes, d1} ]] }} {{attack2=A2: [[ @{selected|weapon1attackcalc}-5 ]] }} {{critconfirm2=Crit!: [[ @{selected|weapon1attackcalc}-5 ]] }} {{damage2=D2: [[ @{selected|weapon1damage} ]] }} {{critdmg2= [[ @{selected|weapon1crit} ]] }} {{attack3=A3: [[ @{selected|weapon1attackcalc}-10 ]] }} {{critconfirm3=Crit!: [[ @{selected|weapon1attackcalc}-10 ]] }} {{damage3=D3: [[ @{selected|weapon1damage} ]] }} {{critdmg3= [[ @{selected|weapon1crit} ]] }} {{attack4=A4: [[ @{selected|weapon1attackcalc}-15 ]] }} {{critconfirm4=Crit!: [[ @{selected|weapon1attackcalc}-15 ]] }} {{damage4=D4: [[ @{selected|weapon1damage} ]] }} {{critdmg4= [[ @{selected|weapon1crit} ]] }} [[({{[[@{selected|weapon1attackcalc}]],[[@{target|armorclass}]]-1}&gt;[[@{target|armorclass}]]})*(1-{0,floor(1-abs([[@{selected|weapon1attackcalc}]]-[[@{target|armorclass}]]))}dl1)*(1-0)+0]]
Theelix said: roll the regular attack macro as normal and then out put a 1 if they hit and a 0 if they missed Target Number / Successes does exactly this: [[ {@{selected|weapon1attackcalc}}&gt;@{target|armorclass} ]]