PDA

View Full Version : Question on Templates



drahkar
January 7th, 2010, 02:23
Does anyone see anything wrong with the following:




Template Code -

<template name="qualityscore">
<numberfield>
<anchored>
<position>belowleft</position>
<offset>0,7</offset>
<size>
<width>32</width>
<height>20</height>
</size>
</anchored>
<frame>
<name>bonus</name>
<offset>5,5,5,5</offset>
</frame>
<keyeditframe>
<name>sheetfocus</name>
<offset>5,5,5,5</offset>
</keyeditframe>
<font>sheetnumber</font>
<script>
function onInit()
if getValue() == 0 then
setValue(12);
end
end
</script>
</numberfield>
</template>

Attempt to use Template -

<qualityscore name="strength" source="qualities.strength.score">
<anchored>
<to>name</to>
<offset>0,7</offset>
</anchored>
</qualityscore>



So far as I can tell this is exactly as it should be. However for some reason the field doesn't show up on the character sheets. Any thoughts?

Foen
January 7th, 2010, 06:33
How are you anchoring it on the character sheet? What is the XML you use between the opening and closing <qualityscore> tags?

drahkar
January 7th, 2010, 07:21
Thats at the very bottom up there.


Attempt to use Template -

<qualityscore name="strength" source="qualities.strength.score">
<anchored>
<to>name</to>
<offset>0,7</offset>
</anchored>
</qualityscore>


Originally I had it anchored to the genericcontrol 'testframe' where I have a libel anchored, but then I changed it to anchor to the label to see if that was what caused the problem. Neither worked.

Right now that's all that there is in the XML for it. I didn't want to add anything more until i got it to at least display correctly.

Foen
January 7th, 2010, 07:36
Hmm a bit hard to tell, but the <offset> tag is duplicated and hence may be causing some problems (you may wish to omit it in the <qualityscore> or else specify mergerule="replace" in the template). What happens if you put some print() statements in the template onInit, do you get anything on the console?

Foen

drahkar
January 7th, 2010, 07:40
Didn't realize I had duplicated that.

Sadly removing the duplicate offset or adding the print() into the template code doesn't seem to have done anything. Its odd cause... Wait..

Oh man. Now I feel really, really dumb. You know how they say the problem always ends up being simple. I'm pretty sure thats the case here. Let me check something.

drahkar
January 7th, 2010, 07:42
*hangs his head* Important note. In order to use a template, you have to actually source the file containing the template definition.

Valarian
January 7th, 2010, 12:33
oops ... done that :p

drahkar
January 7th, 2010, 12:45
:D I blame the late hour and the fact I was completely redoing how the character sheet was being generated.