Starfinder Playlist
  1. #1

    Join Date
    Nov 2020
    Location
    Seattle, USA
    Posts
    161

    Get inventorylist entry from weaponlist entry

    I'm trying to figure out how, given a node in a PC's "weaponlist", to get to the linked node in the "inventorylist". The weaponlist has a value called "shortcut":
    Code:
    <shortcut type="windowreference">
    	<class>item</class>
    	<recordname>....inventorylist.id-00001</recordname>
    </shortcut>
    I'm currently doing this:
    Code:
    local sClass, sRecordName = DB.getValue(vWeaponNode, "shortcut");
    -- s'sClass:  ' | s'item'
    -- s'sRecordName:  ' | s'charsheet.id-00004.inventorylist.id-Longbow'
    local vInvNode = DB.findNode(sRecordName);
    -- s'vInvNode:  ' | databasenode = { charsheet.id-00004.inventorylist.id-Longbow }
    This seems to be easy, and work, but because DB.getValue(vWeaponNode, "shortcut") returns a number of strings, I don't know that I can be certain they will always be consistent, i.e. the second string will contain the path to the inventorylist node.
    Does the above code seem reasonable, or is there a safer way to go about it?

  2. #2
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    I hope someone with more expertise chimes in but I have always done thusly:

    For an entry like:
    Code:
    			<pcclasslink type="windowreference">
    				<class>pcclass</class>
    				<recordname>referencepcclass.fighter@MCSWWB</recordname>
    			</pcclasslink>
    I do:
    Code:
    function onClassLevelChanged(nodeChar)
    	local _, sPCClassRecord = DB.getValue(nodeChar, "pcclasslink")
    Debug.console(DB.getValue(nodeChar, "pcclasslink"))
    	local sClassID = NodeUtils.getLeafNameFromRecord(sPCClassRecord)
    ...
    The print I added above shows:
    Code:
    Runtime Notice: s'pcclass' | s'referencepcclass.fighter@MCSWWB'

    I just do not recall where I looked to see this - probably in other code but it is possible I got it from the Wiki.
    So... yeah - I believe with near certainty you are doing it right

  3. #3
    @dogfisc,

    For the D&D rulesets, that's typically how weapons are set up. Each weapon record is created when a weapon item is added to a character; and removed when the weapon item is removed from a character. The value in the "shortcut" data is the 'link' between the two. This may not be the case in other rulesets, though most copy from the D&D ones.

    Also, you should note that weapon entries can be created independently as well; in which case the "shortcut" data will be empty.

    Regards,
    JPG

  4. #4

    Join Date
    Nov 2020
    Location
    Seattle, USA
    Posts
    161
    Thank you both; I’ll go ahead with this then, so far it’s been working. And Moon Wizard, your comment regarding the D&D rulesets made me realize I didn’t include the ruleset I’m working with (Pathfinder 1e.)

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
  •  
5E Character Create Playlist

Log in

Log in