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:
<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: