Cosmere RPG Beta Launch
  1. #1

    Help with Database path names

    Hi,

    I am trying to determine the path name for nodes that are children of categories so I can extract the node data and use some of it within a dice roll. The database structure in question looks like this:

    <item>
    <category name="Armor" baseicon="0" decalicon="0">
    <category name="Gear" baseicon="0" decalicon="0">
    <category name="Weapons" baseicon="0" decalicon="0">
    <id-00001>
    <accuracy type="string">Ballistic</accuracy>
    <apvalue type="string">2</apvalue>
    <armorarms type="number">0</armorarms>
    <armorfeet type="number">0</armorfeet>
    <armorhands type="number">0</armorhands>
    <armorhead type="number">0</armorhead>
    <armorlegs type="number">0</armorlegs>
    <armortorso type="number">0</armortorso>
    <availability type="string">D / B-B-B / D</availability>
    <concealability type="string">All</concealability>
    <cost type="string">75</cost>
    <damage type="string">5</damage>
    <description type="formattedtext">
    <p></p>
    </description>
    <dmgspecial type="string">Splash</dmgspecial>
    <locked type="number">1</locked>
    <maxammo type="string">20</maxammo>
    <name type="string">Needler Rifle</name>
    <programmu type="string">0</programmu>
    <programstr type="string">0</programstr>
    <range type="string">5/14/30/40</range>
    <reliability type="string">Average</reliability>
    <rof type="string">1</rof>
    <subtype type="string">Rifle</subtype>
    <type type="string">Weapon</type>
    <weight type="number">1</weight>
    </id-00001>
    <id-00003>
    <accuracy type="string">Ballistic</accuracy>
    <apvalue type="string">3</apvalue>
    <armorarms type="number">0</armorarms>
    <armorfeet type="number">0</armorfeet>
    <armorhands type="number">0</armorhands>
    <armorhead type="number">0</armorhead>
    <armorlegs type="number">0</armorlegs>
    <armortorso type="number">0</armortorso>
    <availability type="string">C / C-B-C / C</availability>
    <concealability type="string">LYRAN ALLIANCE</concealability>
    <cost type="string">60</cost>
    <damage type="string">4</damage>
    <description type="formattedtext">
    <p></p>
    </description>
    <dmgspecial type="string">None</dmgspecial>
    <isidentified type="number">1</isidentified>
    <locked type="number">1</locked>
    <maxammo type="string">8</maxammo>
    <name type="string">M&amp;G Service Auto-Pistol</name>
    <programmu type="string">0</programmu>
    <programstr type="string">0</programstr>
    <range type="string">5/20/40/85</range>
    <reliability type="string">Average</reliability>
    <rof type="string">1</rof>
    <subtype type="string">Pistol</subtype>
    <type type="string">Weapon</type>
    <weight type="number">0.65</weight>
    </id-00003>


    I can get the details of the category using the getChildCategories function but I am struggling to get the path name for the next level. The code I am using to see what the function retruns is:

    for k, v in pairs(DB.getChildCategories("item")) do
    -- rCategory = DB.getChildCategories("item");
    sCategoryName = DB.getValue(k);
    Debug.console("Weapon Name = ",k,v,sCategoryName);
    end


    The debug report for this is:

    [14.10.2020 07:12:18] Runtime Notice: s'Item category = ' | { #1 = { s'decal' = #0, s'base' = #0, s'name' = s'' }, #2 = { s'decal' = #0, s'base' = #0, s'name' = s'Armor' }, #3 = { s'decal' = #0, s'base' = #0, s'name' = s'Gear' }, #4 = { s'decal' = #0, s'base' = #0, s'name' = s'Weapons' } }
    [14.10.2020 07:12:18] Runtime Notice: s'Weapon Name = ' | #1 | { s'decal' = #0, s'base' = #0, s'name' = s'' } | nil
    [14.10.2020 07:12:18] Runtime Notice: s'Weapon Name = ' | #2 | { s'decal' = #0, s'base' = #0, s'name' = s'Armor' } | nil
    [14.10.2020 07:12:18] Runtime Notice: s'Weapon Name = ' | #3 | { s'decal' = #0, s'base' = #0, s'name' = s'Gear' } | nil
    [14.10.2020 07:12:18] Runtime Notice: s'Weapon Name = ' | #4 | { s'decal' = #0, s'base' = #0, s'name' = s'Weapons' } | nil


    How can I translate this into a path name so I can extract, say, the name and range strings from a node in the weapon category. I have tried using getValue and getChildren functions but can't get them to work.

    Any help would be appreciated.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    34,051
    Use getChildren, not getChildCategories.

    https://fantasygroundsunity.atlassia...DB#getChildren

    getChildren will return a LUA table with databasenode entries pointing to the id-XXXXX nodes.

    Then use "DB.getValue(v,"name")" to get the value of the name node within (assuming you’re using "for k, v in pairs" to step through them).
    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
    Thanks Trenloe, I will give this a go this evening.

  4. #4
    This has worked. Simple really. I was trying to over complicate things.

    Thanks again Trenloe.

    Now to extract the data I need.

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
  •  
TALES of the VALIANT

Log in

Log in