PDA

View Full Version : Missing function has me stumped



Lithl
June 14th, 2009, 21:23
I've got this template:

<template name="labeledstring">
<stringfield>
<font>sheettext</font>
<frame>
<name>textline</name>
</frame>
<script file="scripts/template_labeledstring.lua" />
</stringfield>
</template>

I use it several times at the top of my character sheet, and one of the things I want to do is change the label in script based on which Exalt type has been selected. For my Caste field, this is working perfectly. for my Anima field, however, the script is claiming that the setLabel function I've created doesn't exist!

The declarations on the character sheet are essentially identical:

<labeledstring name="caste">
<anchored>
<to>player</to>
<position>belowleft</position>
<offset>0,5</offset>
<size>
<width>107</width>
<height>20</height>
</size>
</anchored>
<label>caste</label>
</labeledstring>

<labeledstring name="anima">
<anchored>
<to>caste</to>
<position>righthigh</position>
<offset>4,0</offset>
<size>
<width>107</width>
<height>20</height>
</size>
</anchored>
<label>anima</label>
</labeledstring>

The script isn't complicated:

local labelwidget = nil;

function setLabel(text)
if labelwidget then
labelwidget.setText(string.upper(text));
else
labelwidget = addTextWidget("sheetlabelinline", string.upper(text));

local w,h = labelwidget.getSize();
labelwidget.setPosition("bottomleft", w/2, h/2-5);
end
end

And yet... window.caste.setLabel("caste"); works perfectly fine. window.anima.setLabel("anima"); fails, because setLabel is nil. :confused:

Foen
June 15th, 2009, 06:04
I don't suppose you have another object called 'anima' in the same window?

BTW, you might want to move the two lines of code that set the widget position outside of the if-then-else structure, so that changes to the label text correctly re-position the widget.

Foen

Lithl
June 15th, 2009, 15:03
Well now, don't I feel silly? >,<

Yes, there was a second anima object, which was a stringfield. Renaming it fixed the problem, as well as a minor bug in my tab ordering that I had been ignoring.