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

isDivisibleBy5() without API.

I am working on something really cool for roll templates. I have tested some of the functionality and it works. I just cannot get the math down. I need to take the @{bab}, @{bab2}, @{bab3}, @{bab4} checking each to see if they are divisible by 5 and return a true or false value. I don't care about remainders, I DO NOT want to use API, only a hidden forum field on character sheet and then plug in the attribute into a roll template using a {{#rollTotal() xxx}}. As I said, I've tested the roll total and it functions, its just the math. Any help would be appreciated.
1427998531

Edited 1427999185
Gauss
Forum Champion
No, the only true/false option is the success/fail check and that will not work for what you want to do. At this time the API is the only method available. Note: my comments are regarding macros, if this is a character sheet function I don't know. :)
Try using calc() and modulos somehow to get a zero remainder maybe.
1427999401

Edited 1427999439
Gauss said: No, the only true/false option is the success/fail check and that will not work for what you want to do. At this time the API is the only method available. Just a little idea from out in left field... but... if success/fail is the only true/false option available without API... then couldn't the fields be set to check {d0+@{bab2}}>5 {d0+@{bab3}}>5 {d0+@{bab4}}>5 and then show/hide accordingly?
1428000063

Edited 1428000284
Toby
Pro
Honey: The calc() and what? I've never seen that outside of API. Gauss: I think there should be some way to use min()/max() to say that the number is divisible by five... Here is my logic: @{bab} / 5 = max(x,1). That catches how many times it is divisible by 5 with a maximum result of 1. thereby giving a 0 or a 1... hence true or false. Thus: [[floor(@{test|bab}/5)]] works for at first.. however.. base attacks for successive attacks arnn't in incriments of 5.. they gain in a progression dictated by the Good/Medium/Poor of each class. So you could end up with: First/Second/Third Attacks. 13/8/3 13/5 = 2.6 rounded down to 2 then max(2,1) = 1 8/5 = 1.6 rounded down to 1 then max(1,1) = 1 3/5 = 0.6 rounded to 0 then max(0,1) = error This is my logic and how I am approaching this issue. Granted I am truly terrible at math But I maintain that I have seen equations that function like this. ----------------------- I think I actually mean to use min()... (((@{x} + @{y}) - abs(@{x} - @{y})) / 2)
CSS has calc() options and one of them is modulos. Such as calc(10 mod 5) = 0 since there is no remainder.
1428000538
Gauss
Forum Champion
Chell , I don't know about character sheet fields. I don't deal with character sheet code. But, for macros, or fields that are being dumped into macros rather than giving a 'final answer' the answer would be no. I have already tried to play with the permutations and there is no success/fail method that would then be a usable answer in a macro. The problem is not coming up with success/fail, it is being able to use the output for something else. Toby , as I mentioned, I don't know character sheets. Perhaps there is a max function in them. I don't know. But for macros there is no max function. What works in real world equations and programs is not necessarily programmed into the basic Roll20 functions. It is why the API exists.
1428000919

Edited 1428001025
Gauss
Forum Champion
Toby , are you trying to edit out extra attacks if there is not a high enough BAB?
Gauss the min() max() aren't actually built in functions, but they can be emulated using basic arithmatic as can many mathematical functions. CSS Wizardry - Math Functions . That being said I understand that there is a reason for API, but until you can LINK API to a character sheet so that it cannot be separated and is automatically implemented when the character sheet is loaded I prefer to do as much as possible without. Chell, your {d0+@{bab2}}>5 {d0+@{bab3}}>5 {d0+@{bab4}}>5 idea doesn't work, the way you wrote it... however, if you change the five to a 1..... then... it just might work. I didnt think you could use a calculated value with the < > operators. But after testing it, it appears you can do that. I have some errands to run, but when I get back, I intend to spend the rest of the evening trying to get that to work.
1428001717
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
Toby, if it's a matter of displaying it with a roll template you could create a field that is something like floor(BAB/5) then use that field to determine whether the attack is displayed in the roll template. {{#rollTotal() BAB5 3}} Attack 1 Attack 2 Attack 3 {{/rollTotal() BAB5 3}}
Gauss: Yes Chell: Your suggestion worked perfectly. Steve: That's the basic syntax I have, except I want the attacks to be displayed horizontally on the same line atk 1 / atk 2 / atk3 / atk 4 dmg 1 / dmg 2 / dam 3 / dam 4 ------------------ The original question has been resolved. Yay!
1428030726
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
Steve: That's the basic syntax I have, except I want the attacks to be displayed horizontally on the same line atk 1 / atk 2 / atk3 / atk 4 dmg 1 / dmg 2 / dam 3 / dam 4 ------------------ The original question has been resolved. Yay! What's stopping you from putting it on the same line? {{#rollTotal() BAB5 1}} atk1 {{/rollTotal() BAB5 1}} {{#rollTotal() BAB5 2}} atk1 / atk2 {{/rollTotal() BAB5 2}} {{#rollTotal() BAB5 3}} atk1 / atk2 / atk3 {{/rollTotal() BAB5 3}}