PDA

View Full Version : Creating NPC entries



Ken L
May 27th, 2016, 04:12
I'm not clear on how to create NPC entries, or any entries for that matter, into the database such that they show up.

Looking at
* CoreRPG/campaign/template_campaign.xml
* CoreRPG/campaign/scripts/campaign_button_new.lua
* CoreRPG/campaign/campaign_npcs.xml
* CoreRPG/campaign/record_npc.xml

It appears that I need to create a database node through createChild() which will create a node beneath npc from

ln 8 @ campaign_button_new.lua


local node = window.getDatabaseNode().createChild();


Which I infer that the node is based off the window from where the button is pressed which is the npc list ? I'll try this out later, I'm just sensing around the structure.
I'm assuming that I'd need to get the node of the npc list as my method will be external and not launch from the npc list, so I need a way to get a node by name. From raking through the ruleset reference, I'm not coming up with anything.

damned
May 27th, 2016, 05:07
Im not sure I understand where/what you are doing.
CoreRPG has all that built in. You would normally expand via (layered) ruleset or extension, the attributes of the NPC and all the work on creating the base nodes is already done for you in those files.
Apologies if I have misunderstood what you are trying to do....

Ken L
May 27th, 2016, 06:34
I'm creating an extension that adds NPC entries. The goal here is to get a reference to the npc list node object without relying on receiving it from windowinstance.

Moon Wizard
May 27th, 2016, 06:59
The NPC list is opened from a sidebar button that specifies that a window be opened using the "npclist" class and the "npc" data path. From there, the new button gets the "npc" data path node with the window.getDatabaseNode() call to make the createChild() call.

Basically, to add a record within a ruleset, you have to know the data path where the ruleset expects records of a specific type to be stored. In this case, NPCs are stored under the "npc" data path.

Regards,
JPG

Ken L
May 27th, 2016, 07:52
So how can I get a database node of /root/npc such that I can create entries for it without working off a window connected to the npc 'data path'?

damned
May 27th, 2016, 11:25
what interface are you intending to use to add these?
at the moment when you create objects within FG it is usually done from within the campaign tool (like npcs) and sometimes it can also be done from a char sheet (like inventory) - but these will be stored under the character node and not the item node...

Moon Wizard
May 27th, 2016, 23:28
DB.findNode("npc")
will you get you the correct node in this particular scenario.

Regards,
JPG

Ken L
May 28th, 2016, 14:13
Thanks Moon, Damned.
It seems it was there all along; but I was more fixated on DatabaseNode for some reason.
https://www.fantasygrounds.com/refdoc/DB.xcp#findNode