-
February 28th, 2021, 20:23 #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>
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 }
Does the above code seem reasonable, or is there a safer way to go about it?
-
February 28th, 2021, 21:29 #2
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>
Code:function onClassLevelChanged(nodeChar) local _, sPCClassRecord = DB.getValue(nodeChar, "pcclasslink") Debug.console(DB.getValue(nodeChar, "pcclasslink")) local sClassID = NodeUtils.getLeafNameFromRecord(sPCClassRecord) ...
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
-
March 2nd, 2021, 21:40 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
@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
-
March 2nd, 2021, 22:13 #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