GrimmSpector
March 10th, 2016, 21:49
So I have this bit of code, attached to a windowlist, instancing the class below, gives me this error:
Script Error: [string "charsheet_main:armor"]:1: attempt to set a value for an invalid handler 'labelres'
This code gets called when the windowlist initializes, being passed several entries to setup the order of the list elements, and the label value of one of the controls within it, "itemname", and I want to set it's xml property, "labelres" to a given string value, from what I've read on the scripting guide, it should simple be the object (with hierarchy as necessary) being set equal to a table statement, i.e. labelres = { [1] = "somestringhere" }
Seems that it's not working out, though it's clearly findind the "itemname" control in the window instance.
Window Class:
<windowclass name="charsheet_armor">
<sizelimits>
<maximum>
<height>28</height>
</maximum>
<minimum>
<height>28</height>
</minimum>
</sizelimits>
<sheetdata>
<numbercontrol name="order">
<bounds>0,0,0,0</bounds>
<invisible />
</numbercontrol>
<string_labeled name="itemname">
<anchored position="insidetopleft" offset="0,0" width="70" height="20" />
<labelres>char_label_armor_location</labelres>
</string_labeled>
<string_labeled name="armortype">
<anchored to="itemname" position="right" width="45" offset="5,0" />
<labelres>char_label_armor_type</labelres>
<readonly />
<script>
function onInit()
setValue("Temp.");
end
</script>
</string_labeled>
<numberHolder name="melee" />
<numberHolder name="ballistic" />
<numberHolder name="energy" />
<numberHolder name="explosive" />
<stringcontrol>
<anchored to="armortype" position="rightlow" offset="5,-1" width="60" />
<font>sheetnumber</font>
<readonly />
<center />
<script>
function onInit()
updateArmor();
end
function updateArmor()
local melee = tostring(window.melee.getValue());
local ballistic = tostring(window.ballistic.getValue());
local energy = tostring(window.energy.getValue());
local explosive = tostring(window.explosive.getValue());
setValue(melee .. "/" .. ballistic .. "/" .. energy .. "/" .. explosive);
end
</script>
</stringcontrol>
</sheetdata>
</windowclass>
Windowlist:
<windowlist name="armor">
<anchored to="combatdataframe" position="insidetopleft" offset="10,70" />
<class>charsheet_armor</class>
<datasource>.armor</datasource>
<noscroll />
<skipempty />
<script>
torso = nil;
head = nil;
legs = nil;
feet = nil;
arms = nil;
hands = nil;
local order = 1;
function onInit()
torso = addEntry("torso");
head = addEntry("head");
legs = addEntry("legs");
feet = addEntry("feet");
arms = addEntry("arms");
hands = addEntry("hands");
applySort();
end
function addEntry(name)
local node = getDatabaseNode().getChild(name);
local win = nil;
if not node then
node = getDatabaseNode().createChild(name);
end
for i,w in ipairs(getWindows()) do
if w.getDatabaseNode().getName()==name then
win = w;
end
end
if win then
win.order.setValue(order);
win.itemname.labelres = {
[1] = "char_label_armor_" .. name
}
order = order + 1;
end
return win;
end
function onSortCompare(w1, w2)
return (w1.order.getValue() > w2.order.getValue());
end
</script>
</windowlist>
Maybe someone can help me out here, as the reference must be correct, since the "order" value is being set accurately, and "labelres" is a top level property inside of "itemname"
You can ignore the labelres definition value, as it's just a placeholder string.
The string in the code should workout for the first window to be a string defined in my string values that reads "TORSO", and should thus attach that, instead of throwing the error, and leaving the text as the placeholder.
Script Error: [string "charsheet_main:armor"]:1: attempt to set a value for an invalid handler 'labelres'
This code gets called when the windowlist initializes, being passed several entries to setup the order of the list elements, and the label value of one of the controls within it, "itemname", and I want to set it's xml property, "labelres" to a given string value, from what I've read on the scripting guide, it should simple be the object (with hierarchy as necessary) being set equal to a table statement, i.e. labelres = { [1] = "somestringhere" }
Seems that it's not working out, though it's clearly findind the "itemname" control in the window instance.
Window Class:
<windowclass name="charsheet_armor">
<sizelimits>
<maximum>
<height>28</height>
</maximum>
<minimum>
<height>28</height>
</minimum>
</sizelimits>
<sheetdata>
<numbercontrol name="order">
<bounds>0,0,0,0</bounds>
<invisible />
</numbercontrol>
<string_labeled name="itemname">
<anchored position="insidetopleft" offset="0,0" width="70" height="20" />
<labelres>char_label_armor_location</labelres>
</string_labeled>
<string_labeled name="armortype">
<anchored to="itemname" position="right" width="45" offset="5,0" />
<labelres>char_label_armor_type</labelres>
<readonly />
<script>
function onInit()
setValue("Temp.");
end
</script>
</string_labeled>
<numberHolder name="melee" />
<numberHolder name="ballistic" />
<numberHolder name="energy" />
<numberHolder name="explosive" />
<stringcontrol>
<anchored to="armortype" position="rightlow" offset="5,-1" width="60" />
<font>sheetnumber</font>
<readonly />
<center />
<script>
function onInit()
updateArmor();
end
function updateArmor()
local melee = tostring(window.melee.getValue());
local ballistic = tostring(window.ballistic.getValue());
local energy = tostring(window.energy.getValue());
local explosive = tostring(window.explosive.getValue());
setValue(melee .. "/" .. ballistic .. "/" .. energy .. "/" .. explosive);
end
</script>
</stringcontrol>
</sheetdata>
</windowclass>
Windowlist:
<windowlist name="armor">
<anchored to="combatdataframe" position="insidetopleft" offset="10,70" />
<class>charsheet_armor</class>
<datasource>.armor</datasource>
<noscroll />
<skipempty />
<script>
torso = nil;
head = nil;
legs = nil;
feet = nil;
arms = nil;
hands = nil;
local order = 1;
function onInit()
torso = addEntry("torso");
head = addEntry("head");
legs = addEntry("legs");
feet = addEntry("feet");
arms = addEntry("arms");
hands = addEntry("hands");
applySort();
end
function addEntry(name)
local node = getDatabaseNode().getChild(name);
local win = nil;
if not node then
node = getDatabaseNode().createChild(name);
end
for i,w in ipairs(getWindows()) do
if w.getDatabaseNode().getName()==name then
win = w;
end
end
if win then
win.order.setValue(order);
win.itemname.labelres = {
[1] = "char_label_armor_" .. name
}
order = order + 1;
end
return win;
end
function onSortCompare(w1, w2)
return (w1.order.getValue() > w2.order.getValue());
end
</script>
</windowlist>
Maybe someone can help me out here, as the reference must be correct, since the "order" value is being set accurately, and "labelres" is a top level property inside of "itemname"
You can ignore the labelres definition value, as it's just a placeholder string.
The string in the code should workout for the first window to be a string defined in my string values that reads "TORSO", and should thus attach that, instead of throwing the error, and leaving the text as the placeholder.