Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Home
- >
- Acrobat SDK
- >
- Help with if then code

Explorer
,

Jul 31, 2019

Copy link to clipboard

Copied

I'm working on a RPG character sheet..

I'm trying to calculate a characters total armor class..

I have all the fields set up and labeled..

The total AC bonus = 10 + DEX mod+ proficiency bonus +item bonus..

I have a field that already calculates and generates the "DEX Modifier" field.

The problem is, if you wear a suit of armor it allows you to add your Dex modifier to the ac total

BUT only upto the armors max..

Let's say you wear leather, it allows you to use only +4 max bonus.

So if I have a Dex mod of say +5 it needs to only add the +4 ..

My fields in question is "Dex modifier",

"Ac Dex modifier", " ac Dex modifier max"

I've tried

var A = this.getField("DEX Modifier").value;

var B = this.getField("ac Dex mod max").value;

If (A>B) {event.value = B}

So if ac Dex mod = Dex mod,

But if the Dex mod is greater than the ac Dex mod max, the Dex mod @= ac Dex mod max

Any help is greatly appriciated

Most Valuable Participant

Try this:

var A = Number(this.getField("DEX Modifier").valueAsString);

var B = Number(this.getField("ac Dex mod max").valueAsString);

if (B>0 && B<A) event.value = B;

else event.value = A;

Edit: code fixed

TOPICS

Acrobat SDK and JavaScript

Community Guidelines

Explorer
,

Jul 31, 2019

Copy link to clipboard

Copied

I'm working on a RPG character sheet..

I'm trying to calculate a characters total armor class..

I have all the fields set up and labeled..

The total AC bonus = 10 + DEX mod+ proficiency bonus +item bonus..

I have a field that already calculates and generates the "DEX Modifier" field.

The problem is, if you wear a suit of armor it allows you to add your Dex modifier to the ac total

BUT only upto the armors max..

Let's say you wear leather, it allows you to use only +4 max bonus.

So if I have a Dex mod of say +5 it needs to only add the +4 ..

My fields in question is "Dex modifier",

"Ac Dex modifier", " ac Dex modifier max"

I've tried

var A = this.getField("DEX Modifier").value;

var B = this.getField("ac Dex mod max").value;

If (A>B) {event.value = B}

So if ac Dex mod = Dex mod,

But if the Dex mod is greater than the ac Dex mod max, the Dex mod @= ac Dex mod max

Any help is greatly appriciated

Most Valuable Participant

Try this:

var A = Number(this.getField("DEX Modifier").valueAsString);

var B = Number(this.getField("ac Dex mod max").valueAsString);

if (B>0 && B<A) event.value = B;

else event.value = A;

Edit: code fixed

TOPICS

Acrobat SDK and JavaScript

Community Guidelines

jasonm14517758

Jul 31, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/td-p/10575830
8
Replies
8

Most Valuable Participant
,

Aug 01, 2019

Copy link to clipboard

Copied

Community Guidelines

Reply

Loading...

try67

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575831#M10362
Explorer
,

Aug 01, 2019

Copy link to clipboard

Copied

Basically, the field "AC DEX MOD" equal the field

"DEX MODIFIER".

if "DEX MODIFIER" is greater than the field

"AC DEX MOD CAP"

Then "AC DEX MOD" is equal to

"AC DEX MOD CAP"

If no value in the "AC DEX MOD CAP" field,

Then"AC DEX MOD" is equal to

"DEX MODIFIER

Example:

Dex modifier is +5,

The Dex mod cap is +4.

It will add only +4 in the ac DEX mod field

But if ac Dex mod cap field is empty,

Then AC Dex mod is equal to Dex modifier.

Hope that makes it clearer.

Community Guidelines

Reply

Loading...

jasonm14517758

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575832#M10363
Most Valuable Participant
,

Aug 01, 2019

Copy link to clipboard

Copied

What if "Dex mod cap" is larger than "Dex modifier"?

Community Guidelines

Reply

Loading...

try67

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575833#M10364
Explorer
,

Aug 01, 2019

Copy link to clipboard

Copied

Then it will add the "Dex modifier".

The AC Dex mod field should display the full Dex mod let's say +5.

But if the "ac Dex mod cap" has a value and is a lower value let's say only +4, then the AC Dex mod field should show +4 (in other words equal the AC Dex mod cap value)

Community Guidelines

Reply

Loading...

jasonm14517758

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575834#M10365
Most Valuable Participant
,

Aug 01, 2019

Copy link to clipboard

Copied

Try this:

var A = Number(this.getField("DEX Modifier").valueAsString);

var B = Number(this.getField("ac Dex mod max").valueAsString);

if (B>0 && B<A) event.value = B;

else event.value = A;

Edit: code fixed

Community Guidelines

Reply

Loading...

try67

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575835#M10367
Explorer
,

Aug 01, 2019

Copy link to clipboard

Copied

It's giving me

syntax error missing; before statement

3: at line 4

Community Guidelines

Reply

Loading...

jasonm14517758

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575836#M10369
Most Valuable Participant
,

Aug 01, 2019

Copy link to clipboard

Copied

Sorry, small typo. I fixed it in the original post.

Community Guidelines

Reply

Loading...

try67

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575837#M10371
jasonm14517758
LATEST

Explorer
,

Aug 01, 2019

Copy link to clipboard

Copied

Thank you for your help, that did indeed make it work, outstanding.

Thank you again

Community Guidelines

Reply

Loading...

jasonm14517758

Aug 01, 2019
0
/t5/acrobat-sdk/help-with-if-then-code/m-p/10575838#M10373
Using the Community
Experience League
Terms of Use
Privacy Policy
Cookie preferences
AdChoices
Language:

- Deutsch
- English
- Español
- Français
- 日本語コミュニティ
- Português

Copyright © 2020 Adobe. All rights reserved.