FG Spreadshirt Swag
  1. #1

    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":
    <shortcut type="windowreference">
    I'm currently doing this:
    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
    I hope someone with more expertise chimes in but I have always done thusly:

    For an entry like:
    			<pcclasslink type="windowreference">
    				<recordname>[email protected]</recordname>
    I do:
    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:
    Runtime Notice: s'pcclass' | s'[email protected]'

    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

    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.


  4. #4
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
SWADE Playlist

Log in

Log in