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

Help! HTML newbie, running into math problem

So I've been running a custom tabletop for years. I've recently been attempting to run it on Roll20. I have pretty much no experience with HTML, but I am a quick learner, so I've been trying my hand at making a custom character sheet. There are many problems I've run into, but the one I've been unable to find a fix for (primarily because I don't know how to go about googling it) is a math issue. Basically I'm wondering how to do the equivalent of adding parentheses. I basically have a base stat (e.g. Strength-base), then two separate fields for adding bonuses from various sources (e.g. Strength-bonus, Strength-item), then to round things off, I have the final stat (e.g. Strength). So I have this for all of the main stats in the game. Within the character sheet, all math is done using the base stat. As an example, Max health is calculated with: value="@{Endurance-base}*20+@{Power-base}*10". So if someone equips a set of armor that gives a bonus to endurance, their max health isn't affected. But to get to the point, the problem I've run into (I'm sure is due to my limited knowledge of html) is that within Roll20, when I reference the main stat (e.g. Strength) it references the equation used to come up with Strength: "{@{Strength-base}+@{Strength-bonus}+@{Strength-Item}". Some of you may already know the problem this is causing. Basically when I write a macro that says something along the lines of Strength*2, I get unintended results. On a character with a base strength of 10 and a bonus of 0 and an item bonus of 2, getting a final strength of 12 instead of getting 12*2, I'm getting 10+0+2*2. So basically what I'm asking is, is there a way to put something around the equation in the html so that when the attribute is referenced, it looks more like (10+0+2)*2 than 10+0+2*2? Thanks in advance for any help.
1514537199

Edited 1514538663
vÍnce
Pro
Sheet Author
Try using parentheses "( )" around your attribute value calculations. example <input name="attr_Strength" type="number" value="( @{Strength-base}+@{Strength-bonus}+@{Strength-Item} )" /> I re-read your question... and now I'm not sure I understand the question. ;-(  You can use parentheses within your value calculations to establish an order of operations.  When you reference an attribute's data, only the resolved value will be used.  If you want to show individual attribute values when you hover over an inline roll in chat, use nested inline rolls "[[ ]]".  example <input name="attr_Strength" type="number" value="[[ [[@{Strength-base}]][str-base] + [[@{Strength-bonus}]][str-bon] + [[@{Strength-Item}]][str-item] ]]" 
So thanks so much for the help. I actually realized the whole thing was user error. I'm a bit embarrassed honestly, but I'll go ahead and say what I did wrong for anyone who might stumble on this. The macro I was using to test this was as follows: &{template:default} {{name=Physical}} {{Action Type= Standard}} {{attack=[[d10+@{selected|speed}*2]]}} {{damage=[[@{selected|speed}*@{selected|strength}]] Health}} {{Damage Type= Physical}} While attempting to fix the issue, I started editing the Strength stat, while forgetting that it was the Speed stat that was actually multiplied in the macro. Thanks again for the help. If you hadn't reassured me that the parentheses were supposed to work, I wouldn't have gone back to double check. I honestly wasn't sure if I was supposed to be using "( )", "{ }", "[ ]", or even something completely different, so you really saved me a lot of time.
1514619530
vÍnce
Pro
Sheet Author
cool beans