DICE PACKS BUNDLE

Thread: Combine values

  1. #1

    Combine values

    Can someone point me in the direction to figure out the code to take two values entered on a sheet, add them together, and input the total into a third cell?

    I am currently developing a ruleset for Star Trek Adventures, and I would like to automate some of the stuff. In STA, the total stress for your character is equal to your fitness stat plus your security stat.

    Thank you for your help.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    I’m not in front of my computer so can’t paste the exact code. But there are GUI controls in different rulesets that add together data from other fields.

    Look in the 5E ruleset at the ac.total field (I’m guessing the control might be called actotal) in the character sheet.

    Or, if you want to do it in code then use two getValue commands followed by one setValue.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    I'm briefly in front of a computer... Have a look at the template "number_chartotalcurrenthp" in the 5E ruleset, campaign\template_char.xml file. This is an example of a way of using the <source> command to source data from another database field, it has the <op> property that specifies if that field is an addition or subtraction from the field total.

    Do a find in files in most rulesets for <op> to see other examples.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  4. #4
    Not sure if this is what you are wanting to do but this is how I did it for my Conan extension:



    Here I am taking the Willpower number (7), adding the Expertise number (1) and putting the result in the "TN" number box.

    code for this block:
    Code:
                   <frame_char name="willpowerframe">
    				<bounds>421,313,200,95</bounds>
    			</frame_char>
    
    			<string_label name="willpower" >
    				<anchored to="willpowerframe" position="insidetopleft" offset="15,10" width="80" />
    				<default>WILLPOWER</default>
    				<tooltip textres="need new textres" />
    			</string_label>
    
    			<basicnumber name="willpowerstat" source="willpowerstat">
           			<anchored to="willpowerframe" position="insidetopleft" offset="140,13" width="20" height="17"/>
          		</basicnumber>
    
    
    
                            <string_label name="willpowerlabel" >
    					<anchored to="willpowerframe" position="insidetopleft" offset="20,30" width="180" />
    					<default>Skill..............EX.......FC......TN</default>
    					<font>SmallHeader-8</font>
    					<tooltip textres="need new textres" />
    			</string_label>
    
    			<string_label name="disciplinelabel">
    					<anchored to="willpowerframe" position="insidetopleft" offset="15,45" />
    					<default>Discipline</default>
    			</string_label>
    
    			<basicnumber name="disciplineex">
           			<anchored to="willpowerframe" position="insidetopleft" offset="82,47" width="15" height="15"/>
           			<script>
    					function onValueChanged()
    						local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
    						Debug.console("rActor: ");
    						Debug.console(rActor);
    						
    						local nodeWin = window.getDatabaseNode();
    						Debug.console("nodeWin: ");
    						Debug.console(nodeWin);
    							
    						local attribscore = nodeWin.getChild("willpowerstat").getValue();
    						Debug.console("attribute: ");
    						Debug.console(attribscore);
    						
    						local EX= nodeWin.getChild("disciplineex").getValue();
    						Debug.console("EXPT: ");
    						Debug.console(EX);
    						
    						nodeWin.getChild("disciplinetn").setValue(attribscore+EX);
    					end
    			</script>
          		</basicnumber>
    
          		<basicnumber name="disciplinefc" source="disciplinefc">
           			<anchored to="willpowerframe" position="insidetopleft" offset="110,47" width="15" height="15"/>
          		</basicnumber>
    
          		<basicnumber name="disciplinetn" source="disciplinetn">
           			<anchored to="willpowerframe" position="insidetopleft" offset="140,47" width="20" height="15"/>
          		</basicnumber>
    Hope this helps you.
    Last edited by Ranzarok; August 4th, 2019 at 02:06.

  5. #5
    Do you mean something like this via XML?

    Code:
      <template name="number_chartotalac">
        <number_chartotal>
          <description textres="armorclass" />
          <font>reference-b-large</font>
          <modifiersize>mini</modifiersize>
          <modifierfield>defenses.ac.temporary</modifierfield>
          <source><name>defenses.ac.base</name><op>+</op></source>
          <source><name>defenses.ac.armor</name><op>+</op></source>
          <source><name>defenses.ac.shield</name><op>+</op></source>
          <source><name>defenses.ac.misc</name><op>+</op></source>
        </number_chartotal>
      </template>
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  6. #6
    Thank you, that is all very helpful. I may have more questions going forward. I'm creating my first ruleset, and I am only a novice when it comes to coding.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in