• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need button to have 2 actions

New Here ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

Hey.

I need a button for my D&D charactersheet to have 2 actions.
The actions would be to add several boxes for a total in a final box, or only a base number put in ther final box. It's about having the proficiency bonus box added to the base stat modifier box, with the total placed into a 3rd box.

Example
Checked : Box 1 + Box 2 = Box 3
Unchecked : Box 1 = Box 3Screenshot 2023-01-17 195421.jpg

TOPICS
Windows

Views

329

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

Use this as custom calculation script of "Box 3" and change 'Button'  to your actual radio button name.

var b1 = this.getField("Box 1");
var b2 = this.getField("Box 2");
var check = this.getField("Button").valueAsString;
if(check == "Off")
event.value = b1.value;
else
event.value = Number(b1.value)+Number(b2.value);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

Sorry

I meant to say the checkbox, not button.Screenshot 2023-01-17 221757.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

You also want to show plus sign?

Try this:

var str = this.getField("STR");
var dex = this.getField("DEX");
var check = this.getField("Check Box1").valueAsString;
if(str.valueAsString == "")
event.value = "";
else if(check == "Off")
event.value = "+"+str.value;
else
event.value = "+"+(Number(str.value)+Number(dex.value));

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

Ugh. I forgot something and there isn't an edit button.
OK.
I want the check box to do the following

Checked : Saving throw bonus # = Stat Modifier # + Proficiency Bonus #

Unchecked : Saving throw bonus # = Stat Modifier #

 

I'm just trying to speed up character creation by having the check boxes in the saving throw modifiers box add the proficiency bonus and the stat modifier together in the saving throw bonus box. A+B=C sort of thing. I'm sorry if you're not familiar with Dungeons & Dragons, but the check box in the Saving Throws Modifiers box mean whether or not the character is "proficient". If they are, the proficiency bonus is added to the stat modifier and that's added to a roll made. It was so the box next to the check box had the math done already, so all a player has to do is add that number to the roll.Screenshot 2023-01-17 223129.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

LATEST

The stat modifier field has the same name as saving throw (STR) so what ever you put in one will be in all fields with the same name, so that calculation is not possible unless you rename fields or use "STRmod" field as stat modifier?

Once you fix renaming, first script should work just input correct field names and use it as custom calculation script of "STR" field (Saving throw total bonus) like this:

var b1 = this.getField("STRmod");
var b2 = this.getField("ProfBonus");
var check = this.getField("Check Box1").valueAsString;
if(check == "Off")
event.value = b1.value;
else
event.value = Number(b1.value)+Number(b2.value);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines