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

Checkbox values.

Right now I am having an issue with a macro and a checkbox. The macro uses the checkbox value in a mathematical formula but for some reason won't run if that value is 0 (division). If the checkbox is clicked then it is fine, it takes the value of 2 and does the math with no problem. If I go in and manually make the character have a value of 1 on the attribute the script-macro also runs (though with the wrong result).  My question is, is there a way with sheetworker or another function to have an unchecked value of a checkbox be anything other than 0?
1618496334
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Unfortunately checkboxes use 0 as their unchecked state. That said, what's the macro that you are using this in, and what are the expected results? There is probably a way to adjust the macro so that it will run even if the value is 0.
I play Castles & Crusades. In order to account for the special manuevers and attack options I use a table of buffs/conditions the players can select. Recently I had a Barbarian join the game. One of their abilities (in C&C) is combat sense which reduces the bonus enemies get on sneak, rear, flank, etc attacks by half. I have a checkbox called Barbarian (original I know) that has a value of 2! This is how I wrote it up in the macro... . + [[(floor(@{selected|Flank}/(@{target|Barbarian}+1)))]] [Flank] +[[(floor(@{selected|Rear}/(@{target|Barbarian}+0)))]] [Rear] -[[(@{selected|CalledShot}*8)]] [Called Shot] +[[(floor(@{selected|Sneak}/(@{target|Barbarian}+0)))]]  [Sneak Attack]  The entire attack code looks like this.. --!^4AttackRoll5:|**Attack Roll:** [[ [$Atk0] 1d20 [1d20] +2 [Bane] +@{selected|WeaponHitTotal_1} [Weapon] +@{selected|Animosity} [Animosity] +@{selected|OffensiveFocus} [Offensive Focus]  +[[(floor(@{selected|Flank}/(@{target|Barbarian}+1)))]] [Flank] +[[(floor(@{selected|Rear}/(@{target|Barbarian}+0)))]] [Rear] -[[(@{selected|CalledShot}*8)]] [Called Shot] +[[(floor(@{selected|Sneak}/(@{target|Barbarian}+0)))]]  [Sneak Attack] +@{selected|Enemy} [Favored Enemy] +[[(@{selected|Smite}*@{selected|CharismaMod})]] [Smite] +@{selected|Inspired} [Inspired] +@{selected|Bless} [Bless] +@{selected|Exhort} [Exhort] +[[(@{selected|BackAttack}*4)/(@{target|Barbarian}+0)]] [Back Attack] +@{selected|MiscCombat} [Misc Modifier] -@{selected|Demoralize} [Demoralized] -@{selected|Def} [Defensive Fighting] -[[(@{selected|Evil}*@{target|ProtectionFromEvil})]] [Protection Evil] -[[(@{selected|Good}*@{target|ProtectionFromGood})]] [Protection Good] -[[(@{selected|Lawful}*@{target|ProtectionFromLaw})]] [Protection Law] -[[(@{selected|Chaotic}*@{target|ProtectionFromChaos})]] [Protection Chaos] ]]  (it is actually one of several skipto attack options). As I said above, if the value is 2 it works well. If it is any other number (other than 0) the macro fires (but the results for the rear atacks (et al) are wrong).
1618505949
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, looking at that I'm not sure it's actually dividing by half when the value is set to 2. I'd think that you'd want to do something like what you have for the flank at the start where you add 1 to the barbarian value: + [[(floor(@{selected|Flank}/(@{target|Barbarian}+1)))]] [Flank]  and then the barbarian checkbox's checked value is 1 making the calculated divisor a 2 when checked and a 1 when unchecked.
I did what you said and it works 100%. Thank you.