Skip to main content
Participant
May 6, 2017
Question

Custom Calculation Script Based On Custom Calculation Script

  • May 6, 2017
  • 1 reply
  • 799 views

Hello,

I'm having some troubles with calculating something (This is for a DnD pdf).

I have already gotten loads of scripts working, but my big trouble is when I have a Custom Calculation Script that is dependent upon another Custom Calculation Script to calculate a number...

Let's assume I have:

a) A user input field, called "Dexterity".       (Could store the value: 16)

b) Is a Custom Calcution Script (Let's call it "Modifier" that depends on "Dexterity",

to calculate its value.   (("DEX" - 10) / 2)      (Calculated would be: 3)

My script (Simplified) would be:

event.value = (this.getField("Dexterity").value - 10) / 2;

c) A field (Let's call it "Stealth") that calculates a total value from the "Modifier"

and another User Input Field.     (Such as above value + 2 from the User Input Field, total: 5)

My script (Simplified) would be:

event.value = this.getField("Modifier").value + this.getField("NewUserInput").value;

The problem here is c) ("Stealth")

It simply will not calculate it, if it's based on another calculation script ("Modifier"), but will do it, if I use the code from the b) ("Modifier") calculation.

This would not be a problem, of course, except for the fact that I might have an additional changes to the value of "Modifier" based on something different in the sheet´.

I hoped this would work, so it calculate everything very dynamically and nice, but this problem has stumped me for the last 5-6 hours, and I simply don't know what to google to see if anyone has the same problem as me..

Thanks in advance!

Best Regards.

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
May 7, 2017

Check the calculation order.

Participant
May 7, 2017

I don't completely understand what you mean?

Can you give me an example of what you are trying to say, or an example where you calculate something from another calculation field, so I know it's possible?

Bernd Alheit
Community Expert
Community Expert
May 7, 2017