PDA

View Full Version : Parent nodes?



Oberoten
January 19th, 2008, 21:24
Once again I come back to you with a question on how to do things...
In this case :

I have my windowlist with instances of skills and I have it calculating a XPcost for the level of a skill. :) Now all I need to do is to add the changes in XP to the "XpUsed" tracker which is on the main sheet.

So the question becomes this : How do I properly roll back to find the parent node?



local xp1;
local xpold;
local xpdiff;
xp1 = window.getDatabaseNode().getChild("skill.xp").getValue()
xp2 = window.getDatabaseNode().getChild("skill.oldxp").getValue()
xpdiff = xp1 - xp2

window.getdatabasenode().getchild("xpused").setvalue(xpdiff);
return true;



Seems to try to acess a xpused that should be within the Windowlist, I want the one on the charactersheet.

Tokuriku
January 20th, 2008, 01:25
If I understand correctly, I managed something quite similar but I don't remember if I did it in Lua or XML. You can specify the complete address/path of the variable in the DB structure or move back up a node by using 2 or 3 dots in front of your variable call (I don't remember how many exactly).

Oberoten
January 20th, 2008, 01:32
Veeery intresting. :)

Oberoten
January 20th, 2008, 02:11
And this one solved it...



<script>
function onValueChanged()
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
</script>

Oberoten
January 20th, 2008, 02:41
https://dev.fantasygrounds.com/forums/showthread.php?t=7248&highlight=getchild

For those interested the solution was found in post nr #6 by Foen in this thread. :)

Clever fellow that. :) And infinitely helpful. :)

*genuflects towards his own housealtar for Joshua and Foen whom has given a great deal of help*