## If else statement for Dungeon and dragon

Sep 12, 2018

Copied

Im trying to make it so when you place a number between 1-20 the value for dnd is place in the box above.

DND values:

0,1 = -5

2,3 = -4

4,5 = -3

6,7 = -2

8,9 = -1

10,11 = 0

12,13 = +1

14,15 = +2

16,17 = +3

18,19 = +4

20 = +5  I have a if statement already made but i copied if from a different website and just modified to what i need. I'm not sure how to make x the str field and the print out to STRmod field. Thank you for your help

public class Test {

public static void main(String args[]) {

int x = 0;

if( x == 0 ) {

System.out.print(-5);

}else if( x == 1 ) {

System.out.print(-5);

}else if( x == 2 ) {

System.out.print(-4);

}else if( x == 3 ) {

System.out.print(-4);

}else if( x == 4 ) {

System.out.print(-3);

}else if( x == 5 ) {

System.out.print(-3);

}else if( x == 6 ) {

System.out.print(-2);

}else if( x == 7 ) {

System.out.print(-2);

}else if( x == 8 ) {

System.out.print(-1);

}else if( x == 9 ) {

System.out.print(-1);

}else if( x == 10 ) {

System.out.print(0);

}else if( x == 11 ) {

System.out.print(0);

}else if( x == 12 ) {

System.out.print(+1);

}else if( x == 13 ) {

System.out.print(+1);

}else if( x == 14 ) {

System.out.print(+2);

}else if( x == 15 ) {

System.out.print(+2);

}else if( x == 16 ) {

System.out.print(+3);

}else if( x == 17 ) {

System.out.print(+3);

}else if( x == 18 ) {

System.out.print(+4);

}else if( x == 19 ) {

System.out.print(+4);

}else if( x == 20 ) {

System.out.print(+5);

}

}

}

This code is in Java. It won't work in a PDF file, which uses JavaScript. Similar names, but very different languages...

So you want to set the value of STRmod based on that in STR, right?

If so, you can use something like this as the custom calculation script of STRmod:

`var str = Number(this.getField("STR").valueAsString);if (str==0 || str==1) event.value = -5;else if (str=2 || str==3) event.value = -4;// etc.else if (str==20) event.value = 5;`
TOPICS
Acrobat SDK and JavaScript

Views

86

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more ## If else statement for Dungeon and dragon

Sep 12, 2018

Copied

Im trying to make it so when you place a number between 1-20 the value for dnd is place in the box above.

DND values:

0,1 = -5

2,3 = -4

4,5 = -3

6,7 = -2

8,9 = -1

10,11 = 0

12,13 = +1

14,15 = +2

16,17 = +3

18,19 = +4

20 = +5  I have a if statement already made but i copied if from a different website and just modified to what i need. I'm not sure how to make x the str field and the print out to STRmod field. Thank you for your help

public class Test {

public static void main(String args[]) {

int x = 0;

if( x == 0 ) {

System.out.print(-5);

}else if( x == 1 ) {

System.out.print(-5);

}else if( x == 2 ) {

System.out.print(-4);

}else if( x == 3 ) {

System.out.print(-4);

}else if( x == 4 ) {

System.out.print(-3);

}else if( x == 5 ) {

System.out.print(-3);

}else if( x == 6 ) {

System.out.print(-2);

}else if( x == 7 ) {

System.out.print(-2);

}else if( x == 8 ) {

System.out.print(-1);

}else if( x == 9 ) {

System.out.print(-1);

}else if( x == 10 ) {

System.out.print(0);

}else if( x == 11 ) {

System.out.print(0);

}else if( x == 12 ) {

System.out.print(+1);

}else if( x == 13 ) {

System.out.print(+1);

}else if( x == 14 ) {

System.out.print(+2);

}else if( x == 15 ) {

System.out.print(+2);

}else if( x == 16 ) {

System.out.print(+3);

}else if( x == 17 ) {

System.out.print(+3);

}else if( x == 18 ) {

System.out.print(+4);

}else if( x == 19 ) {

System.out.print(+4);

}else if( x == 20 ) {

System.out.print(+5);

}

}

}

This code is in Java. It won't work in a PDF file, which uses JavaScript. Similar names, but very different languages...

So you want to set the value of STRmod based on that in STR, right?

If so, you can use something like this as the custom calculation script of STRmod:

`var str = Number(this.getField("STR").valueAsString);if (str==0 || str==1) event.value = -5;else if (str=2 || str==3) event.value = -4;// etc.else if (str==20) event.value = 5;`
TOPICS
Acrobat SDK and JavaScript

Views

87

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Sep 12, 2018 0
Sep 13, 2018

Copied

This code is in Java. It won't work in a PDF file, which uses JavaScript. Similar names, but very different languages...

So you want to set the value of STRmod based on that in STR, right?

If so, you can use something like this as the custom calculation script of STRmod:

`var str = Number(this.getField("STR").valueAsString);if (str==0 || str==1) event.value = -5;else if (str=2 || str==3) event.value = -4;// etc.else if (str==20) event.value = 5;`

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Sep 13, 2018 1