Mikey Macabre
January 28th, 2010, 10:21
ok, i am having a huge issue with this. i am working on the combat page. i have armor set to pull numerical values from 4 different boxes and add them together. i also need to add a slightly complicated formula to that total. i cant figure out how. it is adding the other boxes just fine, but it is ignoring the formula. here is my code. i hope someone can help me out.
<linkednumber name="ac" source="ac.totals.general">
<anchored>
<to>acframe</to>
<position>insidetopleft</position>
<offset>20,45</offset>
<size>
<width>61</width>
<height>32</height>
</size>
</anchored>
<frame>
<name>acicon</name>
<offset>4,16,0,24</offset>
</frame>
<font>sheetnumber</font>
<readonly/>
<description>
<text>Accuracy</text>
</description>
<scorefield>abilities.charisma.score</scorefield>
<source>
<script>
function onSourceUpdate()
setValue(math.floor(((sources[scorefield[1]].getValue() + 1) / 2) * 5) + getModifier());
end
function onInit()
addSource(scorefield[1]);
super.onInit();
end
</script>
<op>+</op>
</source>
<source>
<name>body.armor.score</name>
<op>+</op>
</source>
<source>
<name>head.armor.score</name>
<op>+</op>
</source>
<source>
<name>hand.armor.score</name>
<op>+</op>
</source>
<source>
<name>misc.armor.score</name>
<op>+</op>
</source>
<script>
function onSourceUpdate()
setValue(calculateSources());
end
</script>
</linkednumber>
<stringcontrol>
<anchored>
<to>ac</to>
<position>above</position>
<offset>-10,12</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Armor</static>
</stringcontrol>
<numberbox name="bodyarmor" source="body.armor.score">
<anchored>
<to>acframe</to>
<position>insidetopleft</position>
<offset>125,35</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Body armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>bodyarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Body</static>
</stringcontrol>
<stringcontrol>
<anchored>
<to>bodyarmor</to>
<position>left</position>
<offset>5,-8</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Armor</static>
</stringcontrol>
<numberbox name="headarmor" source="head.armor.score">
<anchored>
<to>bodyarmor</to>
<position>right</position>
<offset>25,0</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Head armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>headarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Head</static>
</stringcontrol>
<numberbox name="handarmor" source="hand.armor.score">
<anchored>
<to>headarmor</to>
<position>right</position>
<offset>25,0</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Hand armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>handarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Hand</static>
</stringcontrol>
<numberbox name="miscarmor" source="misc.armor.score">
<anchored>
<to>handarmor</to>
<position>right</position>
<offset>25,0</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Misc armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>miscarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Misc</static>
</stringcontrol>
<linkednumber name="ac" source="ac.totals.general">
<anchored>
<to>acframe</to>
<position>insidetopleft</position>
<offset>20,45</offset>
<size>
<width>61</width>
<height>32</height>
</size>
</anchored>
<frame>
<name>acicon</name>
<offset>4,16,0,24</offset>
</frame>
<font>sheetnumber</font>
<readonly/>
<description>
<text>Accuracy</text>
</description>
<scorefield>abilities.charisma.score</scorefield>
<source>
<script>
function onSourceUpdate()
setValue(math.floor(((sources[scorefield[1]].getValue() + 1) / 2) * 5) + getModifier());
end
function onInit()
addSource(scorefield[1]);
super.onInit();
end
</script>
<op>+</op>
</source>
<source>
<name>body.armor.score</name>
<op>+</op>
</source>
<source>
<name>head.armor.score</name>
<op>+</op>
</source>
<source>
<name>hand.armor.score</name>
<op>+</op>
</source>
<source>
<name>misc.armor.score</name>
<op>+</op>
</source>
<script>
function onSourceUpdate()
setValue(calculateSources());
end
</script>
</linkednumber>
<stringcontrol>
<anchored>
<to>ac</to>
<position>above</position>
<offset>-10,12</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Armor</static>
</stringcontrol>
<numberbox name="bodyarmor" source="body.armor.score">
<anchored>
<to>acframe</to>
<position>insidetopleft</position>
<offset>125,35</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Body armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>bodyarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Body</static>
</stringcontrol>
<stringcontrol>
<anchored>
<to>bodyarmor</to>
<position>left</position>
<offset>5,-8</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Armor</static>
</stringcontrol>
<numberbox name="headarmor" source="head.armor.score">
<anchored>
<to>bodyarmor</to>
<position>right</position>
<offset>25,0</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Head armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>headarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Head</static>
</stringcontrol>
<numberbox name="handarmor" source="hand.armor.score">
<anchored>
<to>headarmor</to>
<position>right</position>
<offset>25,0</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Hand armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>handarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Hand</static>
</stringcontrol>
<numberbox name="miscarmor" source="misc.armor.score">
<anchored>
<to>handarmor</to>
<position>right</position>
<offset>25,0</offset>
<size>
<width>46</width>
<height>32</height>
</size>
</anchored>
<description>
<text>Misc armor value</text>
</description>
<tabtarget>
<next>invent</next>
<prev>mpused</prev>
</tabtarget>
</numberbox>
<stringcontrol>
<anchored>
<to>miscarmor</to>
<position>above</position>
<offset>0,5</offset>
</anchored>
<font>sheetlabelsmall</font>
<static>Misc</static>
</stringcontrol>