Lithl
June 21st, 2009, 06:17
I've got two windowclasses: element_armor, and element_shield. element_armor has fields for soak, mobility penalty, fatigue rating, and notes. element_shield has fields for mobility penalty, fatigue rating, melee defense value, ranged defense value, and notes. They're basically the same, just with gaps in the layout where they don't have fields that the other class does.
I want to put both of these windowclasses in the same windowlist:
<windowlist name="armorlist">
<anchored>
<to>armorframe</to>
<position>insidetopleft</position>
<offset>13,30</offset>
<size>
<width>475</width>
<height>80</height>
</size>
</anchored>
<datasource>.armor_shields</datasource>
<class>element_armor</class>
<allowdelete />
<script>
function onInit()
self.registerMenuItem("Create Armor", "insert", 5);
self.registerMenuItem("Create Shield", "insert", 4);
end
function onMenuSelection(...)
local index = ...;
if index == 5 then
self.createWindow();
elseif index == 4 then
self.createWindowWithClass("element_shield");
end
end
</script>
</windowlist>
The problem is that, while the radial menu correctly has the two create buttons, and adding an armor works perfectly fine... adding a shield doesn't quite work correctly.
While a shield is correctly added to the windowlist, and I can edit the shield's fields perfectly fine, it doesn't get saved to the database. If you can't store multiple windowclass types in a windowlist, then why is there a createWindowWithClass function, and if you can save multiple windowclass types, then what am I doing wrong? :(
I want to put both of these windowclasses in the same windowlist:
<windowlist name="armorlist">
<anchored>
<to>armorframe</to>
<position>insidetopleft</position>
<offset>13,30</offset>
<size>
<width>475</width>
<height>80</height>
</size>
</anchored>
<datasource>.armor_shields</datasource>
<class>element_armor</class>
<allowdelete />
<script>
function onInit()
self.registerMenuItem("Create Armor", "insert", 5);
self.registerMenuItem("Create Shield", "insert", 4);
end
function onMenuSelection(...)
local index = ...;
if index == 5 then
self.createWindow();
elseif index == 4 then
self.createWindowWithClass("element_shield");
end
end
</script>
</windowlist>
The problem is that, while the radial menu correctly has the two create buttons, and adding an armor works perfectly fine... adding a shield doesn't quite work correctly.
While a shield is correctly added to the windowlist, and I can edit the shield's fields perfectly fine, it doesn't get saved to the database. If you can't store multiple windowclass types in a windowlist, then why is there a createWindowWithClass function, and if you can save multiple windowclass types, then what am I doing wrong? :(