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 .
×
May your rolls be merry + bright! 🎄
Create a free account

Is it possible to use conditions for (eg) displaying something

Is there a way (possibly through an API) to be able to write a macro that would compute the damage from an attack, but show NONE or 0 if the attack missed ? 
1644682558
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Depending on what sheet you are using, this may be a built-in option. The D&D 5th Edition by Roll20 Sheet, for example, allows you to turn off automatic damage rolling on the sheet's settings tab. This can be set up as a default in the Campaign Settings page, and can be applied to existing content in the miscellaneous section of the in-game settings tab.
I think its best to leave it like Keith suggests, using an api requires the writer to take into account so many situations about an attack that I doubt its feasible to write code well enough that isn't just easier to simply do the determination in the DM's head in the moment.  Think cover status, mage armor, shield, advantage/disadvantage, manual rerolls, manual crit fishes...too much would break the script while your head could handle it all instantly.  Having auto roll off like Keith suggests and just managing it in the players/yours brains is far simpler and only 1 click(api's would likely require a ton of drop down context queries).  
OK. I understand, that's how I set it up.  But more generally, would it possible to have in a macro something like (excuse my French) if(attack roll+str +pro>target ac), then, if not, then
1644692079
GiGs
Pro
Sheet Author
API Scripter
I think it might be possible, but only through extremely convolted expressions (Ziechael might have some examples). But in principle, it's not meant to be possible to do that - roll20 macros don't handle conditionals (if this, then that), they just do one thing with no branching.
1644694284
The Aaron
Roll20 Production Team
API Scripter
I'm pretty sure you can do that sort of thing with ScriptCards, but I've not used them so I don't know the syntax.
1644697289
David M.
Pro
API Scripter
Definitely possible with scriptcards. Here's an example 5e longsword attack macro from the wiki page that has conditional chat results based on fumble/miss/hit/crit. This particular example also uses the alterbars script to automatically apply the damage, but this is easily removed or changed to a script of your choice.   
David M. said: Definitely possible with scriptcards. Here's an example 5e longsword attack macro from the wiki page that has conditional chat results based on fumble/miss/hit/crit. This particular example also uses the alterbars script to automatically apply the damage, but this is easily removed or changed to a script of your choice.    And just to reiterate my comment above, while this is possible, its going to break in practice as many times in combat there are modifiers to the character sheets AC that we're just eyeballing situationally like cover, shield, parry, maneuvers, and the fact that often we're manually rolling a forgotten advantage.  Great on paper but in use it'lll break more often all for something we all can do in our heads at the table in a second, I can't justify the time spent setting that stuff up to have it make things take longer and use more clicks then just turning off auto roll and using our brains.  
1644701812
David M.
Pro
API Scripter
FWIW, I don't use api scripts for 99+% of standard attacks, either, for similar reasons. Lots of folks do, though, so you'd just need to decide what makes the most sense for your table.
Thanks guys, very useful. DM EDDIE, While I understand your comments, I disagree. The games I am creating are much more centered around intrigues, riddles, puzzles than around fights. My players like to fight not too often, to have simple - albeit adrenalin full - combats, and don't like when there are too many details or lag time for checking some forgotten rules. So for them, anything that automates the combat is a plus...even if it is more work for the DM...
Its more work for everyone.  The templates on the sheet are 3 simple clicks and then click the roll damage button for the hits, any api will have drop downs to pick from and multiple clicks where you can't spam your attacks out to chat.  You'll see.  If quick and simple is what you are after, Keiths method is the way to go.  
1644852045

Edited 1644868004
timmaugh
Forum Champion
API Scripter
I'll throw out the combo of APILogic + ZeroFrame as a way to control line construction based around conditionals... in pseudo-syntax, that would look like: !{&if to_Hit_Roll < target_def_value }The attack missed!{&else}The attack hit!{&end}{&simple} In practice, the to_Hit_Roll might be an actual inline roll that you'd need to get the value from (ZeroFrame syntax: $[[0]].value ), and the target_def_value might be a targeting assignment (standard Roll20 syntax). Also, the outcome of the ELSE (your *hit* conditional) might be a simple macro you want to send to the chat (as above); however it might be an API call, in which case you wouldn't want the {&simple} hanging out at the end of the conditional, applying no matter what the outcome was... you'd want it inside the IF conditional, so that it only survived if the to-hit roll failed: !{&if to_Hit_Roll < target_def_value }The attack missed!{&simple}{&else}!combat-api --arg1 --arg2{&end}
1644864663
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
DM Eddie said: Its more work for everyone.  The templates on the sheet are 3 simple clicks and then click the roll damage button for the hits, any api will have drop downs to pick from and multiple clicks where you can't spam your attacks out to chat.  You'll see.  If quick and simple is what you are after, Keiths method is the way to go.   Keep in mind, my post was a suggested solution to a question. I would never presume to tell anyone how to play.