Fenloh
May 22nd, 2010, 08:15
Thanks a lot for all previous help!
but, as expected here is another one of my problems :)
I have specified a function that sets several fields and labels visible and invisible. That function works fine when i call it from an "onValueChanged" unfortunatly when i reopen the Charsheet all labels and fields are visible again.
I added an onInit() event and call the function from there.
The funny thing is, that the fields get updated correctly, but the Iconcycler is a goner. It gets even funnier... if i print a debug message and do not call the function, the iconcycler is also a goner.
Fenloh
<iconcycler name="weapontype">
<anchored>
<left>
<parent>weaponname</parent>
<anchor>right</anchor>
<offset>5</offset>
</left>
<top>
<parent>weaponname</parent>
<anchor>top</anchor>
<offset>0</offset>
</top>
<size>
<width>50</width>
<height>20</height>
</size>
</anchored>
<parameters>
<icons>button_toggle_one|button_toggle_single|button_togg le_all|button_toggle_single</icons>
<values>Firearm|Melee|Missle|Thrown</values>
<tooltips>Firearm|Melee|Missle|Thrown</tooltips>
<defaulticon>button_toggle_all</defaulticon>
<defaulttooltip>Choose Weapontype</defaulttooltip>
</parameters>
<script>
function onValueChanged()
updateWeaponTypeVisibility();
end
function onInit()
print ("test");
end
function updateWeaponTypeVisibility()
local a = window.getDatabaseNode().getChild("weapontype").getValue();
if a == "Melee" then
window.weaponrecoil.setVisible(false);
window.weaponfiremode.setVisible(false);
window.weaponmagazinetype.setVisible(false);
window.rc.setVisible(false);
window.weaponloadcapacity.setVisible(false);
window.weaponreach.setVisible(true);
window.labelreach.setVisible(true);
window.weaponhasstrengh.setVisible(true);
window.labelhasstrenght.setVisible(true);
window.weaponstrengthbonus.setVisible(true);
elseif a == "Missle" or a == "Thrown" then
window.weaponrecoil.setVisible(false);
window.weaponfiremode.setVisible(false);
window.weaponmagazinetype.setVisible(false);
window.rc.setVisible(false);
window.weaponloadcapacity.setVisible(false);
window.weaponreach.setVisible(false);
window.labelreach.setVisible(false);
window.weaponhasstrengh.setVisible(true);
window.labelhasstrenght.setVisible(true);
window.weaponstrengthbonus.setVisible(true);
else
window.weaponrecoil.setVisible(true);
window.weaponfiremode.setVisible(true);
window.weaponmagazinetype.setVisible(true);
window.rc.setVisible(true);
window.weaponloadcapacity.setVisible(true);
window.weaponreach.setVisible(false);
window.labelreach.setVisible(false);
window.weaponhasstrengh.setVisible(false);
window.labelhasstrenght.setVisible(false);
window.weaponstrengthbonus.setVisible(false);
end
end
but, as expected here is another one of my problems :)
I have specified a function that sets several fields and labels visible and invisible. That function works fine when i call it from an "onValueChanged" unfortunatly when i reopen the Charsheet all labels and fields are visible again.
I added an onInit() event and call the function from there.
The funny thing is, that the fields get updated correctly, but the Iconcycler is a goner. It gets even funnier... if i print a debug message and do not call the function, the iconcycler is also a goner.
Fenloh
<iconcycler name="weapontype">
<anchored>
<left>
<parent>weaponname</parent>
<anchor>right</anchor>
<offset>5</offset>
</left>
<top>
<parent>weaponname</parent>
<anchor>top</anchor>
<offset>0</offset>
</top>
<size>
<width>50</width>
<height>20</height>
</size>
</anchored>
<parameters>
<icons>button_toggle_one|button_toggle_single|button_togg le_all|button_toggle_single</icons>
<values>Firearm|Melee|Missle|Thrown</values>
<tooltips>Firearm|Melee|Missle|Thrown</tooltips>
<defaulticon>button_toggle_all</defaulticon>
<defaulttooltip>Choose Weapontype</defaulttooltip>
</parameters>
<script>
function onValueChanged()
updateWeaponTypeVisibility();
end
function onInit()
print ("test");
end
function updateWeaponTypeVisibility()
local a = window.getDatabaseNode().getChild("weapontype").getValue();
if a == "Melee" then
window.weaponrecoil.setVisible(false);
window.weaponfiremode.setVisible(false);
window.weaponmagazinetype.setVisible(false);
window.rc.setVisible(false);
window.weaponloadcapacity.setVisible(false);
window.weaponreach.setVisible(true);
window.labelreach.setVisible(true);
window.weaponhasstrengh.setVisible(true);
window.labelhasstrenght.setVisible(true);
window.weaponstrengthbonus.setVisible(true);
elseif a == "Missle" or a == "Thrown" then
window.weaponrecoil.setVisible(false);
window.weaponfiremode.setVisible(false);
window.weaponmagazinetype.setVisible(false);
window.rc.setVisible(false);
window.weaponloadcapacity.setVisible(false);
window.weaponreach.setVisible(false);
window.labelreach.setVisible(false);
window.weaponhasstrengh.setVisible(true);
window.labelhasstrenght.setVisible(true);
window.weaponstrengthbonus.setVisible(true);
else
window.weaponrecoil.setVisible(true);
window.weaponfiremode.setVisible(true);
window.weaponmagazinetype.setVisible(true);
window.rc.setVisible(true);
window.weaponloadcapacity.setVisible(true);
window.weaponreach.setVisible(false);
window.labelreach.setVisible(false);
window.weaponhasstrengh.setVisible(false);
window.labelhasstrenght.setVisible(false);
window.weaponstrengthbonus.setVisible(false);
end
end