Oberoten
January 27th, 2008, 10:58
I am trying to get this to autocalculate the values of Xpused in this one for all instances of a windowlist. Of course... this one doesn't work as well as it should. (It gives the wrong final calculations for some reason. Meh)
So I am thinking there should likely be a more useful version of this if I used pairs... But I am knackered if I can figure that one out either.
function onValueChanged()
local test;
local cost;
cost = window.getDatabaseNode().getChild("skill.cost").getValue()
test = window.getDatabaseNode().getChild("skill.level").getValue()
window.getDatabaseNode().getChild("skill.xp").setValue( cost*((test^2)/2 +(test/2)) );
local xp1;
local xp2;
local xp3;
local xpdiff;
xp1 = window.getDatabaseNode().getChild("skill.xp").getValue()
xp2 = window.getDatabaseNode().getChild("skill.oldxp").getValue()
xp3 = window.windowlist.window.getDatabaseNode().getChil d("xpused").getValue()
xpdiff = xp3+ (xp1 - xp2)
window.windowlist.window.getDatabaseNode().getChil d("xpused").setValue(xpdiff);
window.getDatabaseNode().getChild("skill.oldxp").setValue(xp1);
end
So I am thinking there should likely be a more useful version of this if I used pairs... But I am knackered if I can figure that one out either.
function onValueChanged()
local test;
local cost;
cost = window.getDatabaseNode().getChild("skill.cost").getValue()
test = window.getDatabaseNode().getChild("skill.level").getValue()
window.getDatabaseNode().getChild("skill.xp").setValue( cost*((test^2)/2 +(test/2)) );
local xp1;
local xp2;
local xp3;
local xpdiff;
xp1 = window.getDatabaseNode().getChild("skill.xp").getValue()
xp2 = window.getDatabaseNode().getChild("skill.oldxp").getValue()
xp3 = window.windowlist.window.getDatabaseNode().getChil d("xpused").getValue()
xpdiff = xp3+ (xp1 - xp2)
window.windowlist.window.getDatabaseNode().getChil d("xpused").setValue(xpdiff);
window.getDatabaseNode().getChild("skill.oldxp").setValue(xp1);
end