Spyke
August 2nd, 2008, 19:03
I'm having difficulty with a script in my ruleset when in local mode where the fields aren't available from the campaign database. I've read through a number of threads, particularly:
https://www.fantasygrounds.com/forums/showthread.php?t=7248&highlight=getvalue+local
but I'm still stuck.
My function collects the values of dozens of number fields and sets the total in a points total field. It works fine in host mode, as the code can find the character sheet root node using window.getDatabaseNode(). However, as noted in the thread above, this returns nil in local mode.
So, presumably in local mode all the number fields are treated as unbound, as we don't have access to the database.
Is it still possible to get and set the values of the fields on the character sheet? I can't seem to find out how to either reference the database nodes or reference the controls themselves.
Example:
I have a numberfield with name = "strength_points" and source = "stats.strength_points". The control is in the sheetdata in a windowclass called "charsheet_main". My script is currently called from the tab control down the side of the character sheet, reacting to the onClickDown() event.
Everything I try returns a nil value, including:
window.getDatabaseNode().getChild("stats.strength_points").getValue()
DB.findNode("stats.strength_points").getValue()
strength_points.getValue()
window.strength_points.getValue()
charsheet_main.strength_points.getValue()
Any help would be much appreciated!
Edit:
Further investigation shows that I can get to any control on the current window (using window.controlname.getValue()), but the problem arises when I try to reference a control on a different window. Interface.findWindow() seems like it should help, but I've had no joy with it.
I have a top-level window called "charsheet", and subwindows containing the controls such as "main" and "notes". In local mode the datasources return null, which is probably why findWindow() isn't working.
Spyke
https://www.fantasygrounds.com/forums/showthread.php?t=7248&highlight=getvalue+local
but I'm still stuck.
My function collects the values of dozens of number fields and sets the total in a points total field. It works fine in host mode, as the code can find the character sheet root node using window.getDatabaseNode(). However, as noted in the thread above, this returns nil in local mode.
So, presumably in local mode all the number fields are treated as unbound, as we don't have access to the database.
Is it still possible to get and set the values of the fields on the character sheet? I can't seem to find out how to either reference the database nodes or reference the controls themselves.
Example:
I have a numberfield with name = "strength_points" and source = "stats.strength_points". The control is in the sheetdata in a windowclass called "charsheet_main". My script is currently called from the tab control down the side of the character sheet, reacting to the onClickDown() event.
Everything I try returns a nil value, including:
window.getDatabaseNode().getChild("stats.strength_points").getValue()
DB.findNode("stats.strength_points").getValue()
strength_points.getValue()
window.strength_points.getValue()
charsheet_main.strength_points.getValue()
Any help would be much appreciated!
Edit:
Further investigation shows that I can get to any control on the current window (using window.controlname.getValue()), but the problem arises when I try to reference a control on a different window. Interface.findWindow() seems like it should help, but I've had no joy with it.
I have a top-level window called "charsheet", and subwindows containing the controls such as "main" and "notes". In local mode the datasources return null, which is probably why findWindow() isn't working.
Spyke