PDA

View Full Version : Data node pathing for ActorManager.getActor()



dstuffle
September 14th, 2013, 18:35
When one of my controls is dragged, it kicks off a script. Part of that script is to use the ActorManager.getActor() function from the scripts/manage_actor.lua file. The parameters for this function are ActorType (the type of actor) and ether a string or a database node (in my case it's tying to use a database node).

My problem is that I don't know how to point to the database node I want to send it. The examples I have from other places in the ruleset I'm tweeking are like "window.getDatabaseNode()" and "window.windowlist.window.getDatabaseNode()" nether of which appear to be pointing to anything (when other code tries to use the referenced node, it throws an error when it tries to get a child [a nil value]).

How do I determine what (if anything) is at "window.getDatabaseNode()"? If I can find out where that is, I might be able to point the path to the right spot. I've tried to use the print() function to display what is returned from ActorManager.getActor("npc", window.getDatabaseNode()); but that also throws a nil error.

Or does there being no database node there mean that I forgot to specify a data attribute in the dragging control, or something?

Thanks.

Dakadin
September 15th, 2013, 00:41
Try using Debug.chat(window.getDatabaseNode()) or Debug.console(window.getDatabaseNode()).

dstuffle
September 15th, 2013, 01:24
Thanks for the help. It looks like the "window" here is a child of the window that would have the data that I need.

How do I navigate to the Parent node? I've tried "window.getParent()", "window..", and "window.window". No joy.

I know that ".." mean the parent node in the database, is there a similar notation for the window controls structure?

Dakadin
September 15th, 2013, 02:10
Once you get the database node with window.getDatabaseNode() you can use the result to get the parent. Here's an example:


local windowNode = window.getDatabaseNode();
local parentNode = windowNode.getParent();


You can string a few getParent calls together to move further up the chain.

dstuffle
September 15th, 2013, 02:54
Ok, that worked.

Moon Wizard
September 15th, 2013, 03:03
For windows embedded in windowlists, you can also use
window.windowlist.window.getDatabaseNode()

For windows embedded in subwindows, you can use
window.parentcontrol.window.getDatabaseNode()

Window objects consist of the window instance with a set of controls. The controls can access the window instance through the "window" variable, and the window can access the controls by variables equal to the "name" of the control in the windowclass definition.

Some controls (subwindows and windowlists) can contain nested window instance objects.

So to navigate between nested windows, you have to alternately access windows and controls to get to where you want.

Regards,
JPG