5E Product Walkthrough Playlist
  1. #1

    Creating a child node with autogenerated name

    Both DB.createChild and databasenode.createChild have the following documented for the 'name' parameter:

    Code:
    name   (string)   [optional]
    A relative node identifier specifying the child node to find. If this parameter is omitted, a new unique node name will be generated.
    How do you omit a parameter? Passing in nil or "" to these functions causes a script error. Omitting the parameter entirely, for example myNode.createChild("string") or DB.createChild(myNode, "string"), creates a node named string instead of autogenerating a name. Is this documentation incorrect?

    In general, how do you directly create a typed node with an autogenerated name?
    Last edited by darrenan; June 2nd, 2021 at 20:51.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,593
    <dbnode>.createChild() and DB.createChild(<dbnode>) will create a new intermediary node with the usual auto generated id-XXXXX name. I don't think you can create an auto generated node name and specify a type.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Ok, seems like I can get around it by just adding one more level of node.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,593
    The usual naming convention is that intermediary nodes will have id-XXXXX or a name (but no type) - the vast majority will be id-XXXXX, you'll see that everywhere in FG db.xml (campaign and modules). I'd stick with that naming if you're creating a child that will have multiple entries under it.

    If it's a child with just one entry, then use a meaningful unique name.

    I'm not sure what you're trying to do, so can't make definite recommendations. So I don't know if adding one more level of code is the way to go or not.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  5. #5
    If you are creating a value node; then you should probably be using a unique name anyway.
    The auto-generated child names are more for branch nodes that represent whole records.

    Regards,
    JPG

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Dungeons & Dragons 2024 Core Rulebooks Pre-Order

Log in

Log in