PDA

View Full Version : openWindow() returning nil in classic?



pr6i6e6st
July 7th, 2020, 03:35
alright, i got a weird one. in Fantasy Grounds Unity, the following line returns a windowinstance which i can use to get the databasenode from.

local aNode = Interface.openWindow("npc", "npc.");
Debug.console(aNode);
Debug.console(DB.getChildren("npc"));
aNPCDetails.node = aNode.getDatabaseNode();
Debug.console(aNPCDetails.node);

in Fantasy Grounds Classic, aNode comes up nil. What do i need to do so that we create a new npc and return its databasenode in both versions?

Moon Wizard
July 7th, 2020, 08:40
"npc." is not a valid database path. That's probably the issue.

JPG

pr6i6e6st
July 7th, 2020, 10:00
"npc." is not a valid database path. That's probably the issue.

JPG

Neat/strange that unity can ignore that and create the node. So would I need to createChild() first? Or get a list of children from the npc node, count each and then create a string that reads like local sNode = “npc.id-“ .. 00000 + nCount . . “”;

Trenloe
July 7th, 2020, 11:02
Use createChild: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4063529/DB#createChild or https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4063650/databasenode#createChild

Either will create a unique ID (in the form of id-XXXXX) if the name parameter is omitted, and return a databasenode which can be used in Interface.openWindow

pr6i6e6st
July 7th, 2020, 11:10
Use createChild: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4063529/DB#createChild or https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4063650/databasenode#createChild

Either will create a unique ID (in the form of id-XXXXX) if the name parameter is omitted, and return a databasenode which can be used in Interface.openWindow

Awesome, I’ll give it a whirl later. I thought maybe that’s the extra step needed but I was struggling with the name part. Thank you