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

Wrong Calculated Formula

I have a calculated field for a custom character sheet that sum up HP like this: <input type="number" name="attr_MAXHP" value=" [[1 + (3 * @{Body}) + (2 * @{Mind}) + (3 * @{Luck}) + @{BonusHP}]] " class="sheet-highlight-value" disabled="true" title="1 + 3xBody + 2xMind + 3xLuck" /> Where Body, Mind and Luck are these: <td><input type="number" name=" attr_BaseBody " readonly="readonly" value="0" /></td> <td><input type="number" name=" attr_BonusBody " value="0" /></td> <td><input type="number" name=" attr_Body " value=" [[@{BaseBody} + @{BonusBody}]] " class="sheet-highlight-value" disabled="true" /></td> <td><input type="number" name=" attr_BaseMind " readonly="readonly" value="0" /></td> <td><input type="number" name=" attr_BonusMind " value="0" /></td> <td><input type="number" name=" attr_Mind " value=" [[@{BaseMind} + @{BonusMind}]] " class="sheet-highlight-value" disabled="true" /></td> <td><input type="number" name=" attr_BaseLuck " readonly="readonly" value="0" /></td> <td><input type="number" name=" attr_BonusLuck " value="0" /></td> <td><input type="number" name=" attr_Luck " value=" [[@{BaseLuck} + @{BonusLuck}]] " class="sheet-highlight-value" disabled="true" /></td> And bonus HP is a simple input type number field: <input type="number" name=" attr_BonusHP " value="0" class="sheet-highlight-value" /> I have a worker script that changes the value of BaseBody, BaseMind and BaseLuck, setting the character's base abilites. When the worker runs the MAXHP is calculated perfectly, but when I change the values of BonusBody, BonusMind or BonusLuck in the sheet interface, the MAXHP field calcs wrong. For each +1 I add into these "bonus" inputs, the MAXHP increases by +1 (not by each ability multiplier stated in the formula). Ideas?
1531839674

Edited 1531840039
Rago
Pro
Update. If I change the MAXHP formula... from this: [[1 + (3 * @{Body}) + (2 * @{Mind}) + (3 * @{Luck}) + @{BonusHP}]] to this: [[1 + (@{Body} * 3) + (@{Mind} * 2) + (@{Luck} * 3) + @{BonusHP}]] The resulting MAXHP is different - it calcs wrongly even after setting the base abilities using the worker script. It seems that the "[[" and "]]" from the attr_ABILITY fields, that sum up the BASE+BONUS are being ignored, in a way so... 3 * [[@{BaseLuck} + @{BonusLuck}]] is turned to 3 * @{BaseLuck} + @{BonusLuck}. That's... unexpected.
I changed my formula to "[[1 + ((@{Body}) * 3) + ((@{Mind}) * 2) + ((@{Luck}) * 3) + @{BonusHP}]]" and now it works as expected. But the question stays - is it expected (the missing "[[ ]]") or is it a bug?
1531842558

Edited 1531842666
GiGs
Pro
Sheet Author
API Scripter
I havent tested this, but try changing the MAXHP calculation to [[1 + [[3 * @{Body}]] + [[2 * @{Mind}]] + [[3 * @{Luck}]] + @{BonusHP}]] You could also replace @{Body} with @{BaseBody} + @{BonusBody} - basically bypassing the intermediate stat. A better solution would be to replace the autocalc fields with sheetworkers. It's more robust.