PDA

View Full Version : xml formula issue



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>

Mikey Macabre
January 29th, 2010, 22:47
nevermind guys, i got it figured out. on the other hand, i am having trouble with something else. i am getting an error

Script Error: [string "scripts/template_linkednumber.lua"]:63 Invalid argument to createChild}
I havent changed anything in the scripts folder yet so i dont know how to fix this??

Moon Wizard
January 30th, 2010, 00:39
It sounds like you might have a bad parameter in one of the linkednumber fields you are using. Also, I noticed that you have a script tag embedded in the source tag in your first post, which might be part of the problem. Script tags are only valid one level down from the control definition.

If you are still having problems, re-post your field that uses linkednumber.

Regards,
JPG