5E Character Create Playlist
  1. #1
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075

    DB.getValue() parameter double-check

    [RESOLVED]

    I see in the 5E addCharRef code the line:

    for _,v in pairs(aCharClassNodes) do
    local _,sExistingClassPath = DB.getValue(v, "shortcut", "", "");

    I am not sure what the 2nd "" stands for. On the API page it only mentions 3 arguments.
    https://www.fantasygrounds.com/refdoc/DB.xcp#getValue

    I understand extras in Lua are "ignored", but checking in case it is because of an enhancement to the API that didn't make the web page.
    Last edited by Varsuuk; March 31st, 2019 at 03:35.

  2. #2
    Quote Originally Posted by Varsuuk View Post
    I see in the 5E addCharRef code the line:

    for _,v in pairs(aCharClassNodes) do
    local _,sExistingClassPath = DB.getValue(v, "shortcut", "", "");

    I am not sure what the 2nd "" stands for. On the API page it only mentions 3 arguments.
    https://www.fantasygrounds.com/refdoc/DB.xcp#getValue

    I understand extras in Lua are "ignored", but checking in case it is because of an enhancement to the API that didn't make the web page.
    Shortcut contains a "class" and "record" values.

    local sClass, sRecord = DB.getValue(node, "shortcut", "", "");

    DB.setValue(nodeClass, "shortcut", "windowreference", sClass, sRecord);

    sClass = "item" or "charsheet" or "npc".
    sRecord="item.id-00001" or "charsheet.id-00312"
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  3. #3
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    I GET it now. I read the "function getValue( sourcenode, [subpath], [default] )" and would have expected: "function getValue( sourcenode, [subpath], [default, ...] )" or some symbology to indicate multiple defaults.
    I knew it returned two values for this method (I print these generally to find out) but it never occurred to me that the it was for multiple "defaults" to return - which of course makes sense


    The key, of course, that I missed being the "(s)"
    default (...) [optional] The value(s) to be returned if getValue fails. (node does not exist; or non-value node)




    Thanks

  4. #4
    Quote Originally Posted by Varsuuk View Post
    I GET it now. I read the "function getValue( sourcenode, [subpath], [default] )" and would have expected: "function getValue( sourcenode, [subpath], [default, ...] )" or some symbology to indicate multiple defaults.
    I knew it returned two values for this method (I print these generally to find out) but it never occurred to me that the it was for multiple "defaults" to return - which of course makes sense


    The key, of course, that I missed being the "(s)"
    default (...) [optional] The value(s) to be returned if getValue fails. (node does not exist; or non-value node)




    Thanks
    Ah, yeah, the bits on the end set it's defaults if it's nil. That's why I almost ALWAYS use DB.getValue(node,"something","default") and never node.name.getValue(). I almost always want something back even if it's my default.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

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
  •  
DICE PACKS BUNDLE

Log in

Log in