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 .
×

Remainder values :(

I dont get why this isnt working :( if agility is 2 this should output 0 right? what am I missing value='((5+floor(@{agility}/2))%10)'
1610690720
GiGs
Pro
Sheet Author
API Scripter
The % is actually modular arithmetic, which is similar to but not quite a remainder.  The % operation gives you the number left over after you subtract the largest multiple of the modulus. So lets say you do 64 % 10: the first step (behind the scenes) is to find out how many times 10 goes into 64, which is 6. It then subtracts that modulus (10) multiplied by the number (6x10 - 60), to give you the remainder 4. If you do 4%10, the same thing happens. First calculate how many times 10 goes into 4, which is 0. You then subtract that result (0) multiplied by the % (10) which is (0 * 10) also zero. So 4 - 0 gives a result of 4. So when using %, if the number on left is smaller than the number on the right, you always get back the number on the left (not 0). Things get even weirder if the number on the left is negative, so we'll ignore that. Note that your are performing modular arithmetic if, say, it is now 7 AM, and you have an appointment in 40 hours. What time of day will that appointment offur on. That is (40+7) % 24: first see how many time 24 goes into 47: we ow know the appointment is 1 day later. Now 47 % 24 gives 23, so the appointment is 23 hours into the day. If we want to convert that into AM/PM, so lets do a quick modular calculation  (23 % 12) to learn that is at 11PM. A weird time for an appointment! But we now now the appointment is 11PM tomorrow.
Hmm, interesting. Ok well is there a way to do what I want? So I am trying to calculate the value of AP for my sheet. This is what I am trying to get: (½ AG+5), every point after 10 AG awards 1 point of AP Basically, agility normalizes at 11+ but is half rounded down plus 5 until then.
1610701944
GiGs
Pro
Sheet Author
API Scripter
You could use the keep highest modifier, which looks like {calculation, minimum}kh1  {floor(@{agility}/2 -5), 0}kh1 its -5 here, because its +5 then -10 To account for the over 10 part. This will give 0 below 10, and 1 per point above 10.
1610744319

Edited 1610744379
oh that would do it Hmm i get "The specified value "12 + {floor(0 + 2/2 -5), 0}kh1" cannot be parsed, or is out of range." When trying to use it though it doesn't display anything 12 is just the agility i had changed it to at that point
1610765059
GiGs
Pro
Sheet Author
API Scripter
Can you post the full macro? The snippet above doesnt match the earlier macro, so its hard to tell when's going on.
{floor(@{agility}/2 -5), 0}kh1 I just put that into the HTML on the character sheet because I wanted to see it but it does not output any number <td><input type="number" class="sheet-number" name="attr_base-actionpoints" value='{floor(@{agility}/2 -5), 0}kh1' disabled="true" /></td>
1610772109
GiGs
Pro
Sheet Author
API Scripter
I am rusty with autocalc fields because I don't use them any more, so I'm trying to remember what might be the issue: Does your agility attribute have a default value? An attribute that doesnt have a valid value can cause issues. What does the code for your agility attribute look like? If its an autocalc, there might be a syntax issue. How is this attribute actually used? Is it just meant to display a number on the character sheet?
1610794666

Edited 1610795826
Yes in this case this is only used to display a number in the character sheet based on the users agility. With the previously mentioned values. I am not sure what the autocalc is. I ah editing the Fallout 2.0 character sheet that is on the site to fit the game that I am running, I am really new to the API for these sheets but I am pretty comfortable with html/css. Just trying to edit the Action points value to fit my needs I don't think I have set a default value. This is literally what is in the TD.  <td><input type="number" class="sheet-number" name="attr_base-actionpoints" value='{floor(@{agility}/2 -5), 0}kh1' disabled="true" /></td>
1610796262
GiGs
Pro
Sheet Author
API Scripter
as a test, manually alter your ability attribute, and see if the action point score displays properly. An autocalc is any attribute that has disabled="true"  in its definition, like the base-actionpoints attribute you just posted.
Yes, i changed it to a 5 and it displayed properly
1610850138
GiGs
Pro
Sheet Author
API Scripter
So its probably just that you need to set a default value for your attributes. Whatever your agility input says, add value="0" to it, or whatever value you want to show up as a default value.
Hmm, this may be easier here is everything for the sheet in the pastebin. It's the one on line 133.&nbsp;&nbsp; <a href="https://pastebin.com/EyxYN0tL" rel="nofollow">https://pastebin.com/EyxYN0tL</a> When I try to get it to work it does not display anything, if I set the value to 0 as you suggested it just sets it to 0 and the number is not changed afterward. Previously it calculated something different just half agility + 5 and it does that fine but that's not exactly what i want. I just want agility/2 +5, until 10 then 1 point per point after that.
1610867325
GiGs
Pro
Sheet Author
API Scripter
I see that the agility score itself is an autocalc field made up two other attributes. This is likely the problem. Try changing your AP calculation to account for this, like &lt;td&gt;&lt;input type="number" class="sheet-number" name="attr_base-actionpoints" value='{floor((@{agility})/2 -5), 0}kh1' disabled="true" /&gt;&lt;/td&gt; You also want to change line 106 from &lt; td &gt;&lt; input type = "number" class = "sheet-number" name = "attr_agility_base" value = "" / &gt;&lt; / td &gt; to &lt; td &gt;&lt; input type = "number" class = "sheet-number" name = "attr_agility_base" value = "0" / &gt;&lt; / td &gt; to give it a proper, numerical default value
Ok so unfortunately that still isnt working. I did find an old post by Brian stating that kh1 do not work on autocalc values. BUT I also found a post by him saying how to do min max values and I managed to put something together that works. Honestly, I wasn't expecting it to. OMG&nbsp; &lt;td&gt;&lt;input type="number" class="sheet-number" name="attr_base-actionpoints" value='((((@{agility} + 10) + abs(@{agility} - 10)) / 2) - 10) + (((floor(@{agility}/2 + 5) + 10) - abs(floor(@{agility}/2 + 5) - 10)) / 2)' disabled="true" /&gt;&lt;/td&gt; It seems like craziness!! But it works lol. I really appreciate all the time you put into helping me, I absolutely would not have known what to look for without your help. Thanks so much!!
1610941171
GiGs
Pro
Sheet Author
API Scripter
Orginlock said: I did find an old post by Brian stating that kh1 do not work on autocalc values.&nbsp; That explains it. I'd forgotten about that. Its funny, another poster I was helping just yesterday is using that Min/Max method too.