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 and Dividing by 0

Everyone,  The following macro for Shadowrun 3rd ed works absolutely fine until the bold section ends up equaling 0.  /em @{selected|character_name} takes a hit! If the attack was M damage or higher @{selected|character_name}'s Ballistic Armor is reduced permanently by [[{floor(?{Power of the Weapon|0}/ @{selected|Armor-Ballistic} ),1}kh1]] due to Armor Degradation.  There is more to the macro, but I think this is what is breaking. I don't think Roll20 likes attributes being 0. Is there anyway to get this to work properly?
1534908094
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Well, it isn't that the attribute is 0 (or at least not in a general "attributes can't be 0" way). The problem is a basic math issue. You can't divide something by 0, so you just need to add another kh or kl around the attribute: {@{selected|Armor-Ballistic},1}kh1 I'm assuming that the attribute is 0 or greater here.
Thanks, Scott. Tried that but Roll20 didn't like it. Produced nothing. I think I'm going to just create a button called "No Armor" and have this: /em @{selected|character_name} takes a hit! Basically the Macro will then call out their body attribute and go from there. You are right, you can't divide by 0. The Armor Degradation reduces properly until it reaches 0 (no Armor). So, if I take the 0 out of the equation and I have them roll the "No Armor" macro it'll "fix" the issue.  Thanks again for you time, Scott.
1534953782
The Aaron
Pro
API Scripter
If @{selected|Armor-Ballistic} contains a formula with dice instead of a number, you'd have to use the dice syntax for grouping: {@{selected|Armor-Ballistic}, 1d1 }kh1