Fantasy Grounds Merchandise
  1. #1

    Getting Links from LinkList from FormattedText

    Can anyone help me figure out how to get the links from a linklist from a database node's formattedtext description node? I feel like I've tried everything.

    Here's an excerpt from a module's client.xml file with some text changed to avoid posting any copyrighted data:
    Code:
    		
                     <races>
    			<customrace>
    				<description type="formattedtext">
    <p><b>RACIAL TRAITS</b></p>
    <p><b>Average Height</b>: 5'8" - 6'4"</p>
    <p><b>Average Weight</b>: 210 - 310</p>
    <p><b>Ability scores</b>: +2 AbiltityOne, +2 AbilityTwo or +2 AbilityThree</p>
    <p><b>Size</b>: Medium</p>
    <p><b>Speed</b>: 6  </p>
    <p><b>Vision</b>: Normal</p>
    <p><b>Languages</b>: Common</p>
    <p><b>Skill Bonuses</b>: +2 SkillOne, +2 SkillTwo.</p>
    <p><b>CustomRace Features</b></p>
    				<listlink>
    					<link class="powerdesc" recordname="reference.features.customraceacidresistance@Example Module PC Options">Acid Resistance</link>
    					<link class="powerdesc" recordname="reference.features.customracebarbedbody@Example Module PC Options">Barbed Body</link>
    					<link class="powerdesc" recordname="reference.features.customracerazorstorm@Example Module PC Options">Razor Storm</link>
    				</listlink>
    <p><b>CustomRace Racial Attack </b></p>
    				<listlink>
    					<link class="powerdesc" recordname="reference.powers.razorstorm@Example Module PC Options">Razor Storm</link>
    				</listlink>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore e.</p>
    <p>orem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore e.</p>
    <p><b>PHYSICAL QUALITIES</b></p>
    I've been trying every variation of DB methods (getPath, findNode, getChildList, getc.) I can think of to get a hold of these link nodes but I can't crack the right syntax to do what I want to do. The main access I have is sRecord which I'm getting from some drag and drop shortcut data.
    Code:
    Debug.console("sRecord:",sRecord);
    This returns
    Code:
    s'sRecord:' | s'reference.races.customrace@Example Module PC Options'
    So far the closest I've gotten is using DB.findNode(DB.getPath(sRecord, "description")) and then sticking that into DB.getValue() but that returns all the text in there, but at least it includes the link tags.
    I was hoping there was some good way to use DB.getChildren, or DB.findNode, or DB.getPath, or something to just get the links without having to do a bunch of xml processing in Lua, especially since I'm fairly new at it. I thought the trick was using some variation of getChildren, since the links seem to be child nodes of linklist which seems to be a child of description, but DB.getChildCount(DB.findNode(DB.getPath(sRecord, "description"))), keeps returning 0 so maybe that's not right, or I'm misunderstanding how to phrase it.

    Does anyone know what the easiest way to do this is? Am I making sense here or was my explanation confusing?
    Last edited by SieferSeesSomething; November 30th, 2024 at 02:32.

  2. #2

  3. #3
    Quote Originally Posted by damned View Post
    you will need to use one or more of the various lua string match functions to further whittle your result down.
    I had a feeling that was what I was going to need to do, but thanks for confirming it. I probably haven't found the most efficient solution, but I think I found one for now at least. Thanks!

    EDIT: For future people who may run into a similar issue who are wondering what I did, here is my solution as of this moment (until I no doubt find a better way later).
    Code:
    	local sText = DB.getValue(sRecordDescriptionNode);
    	local sPattern = '<link class="powerdesc" recordname="reference.features.(%w+)@Example Module PC Options">'
    	local sLink = string.gmatch(sText, sPattern);
    	for w in sLink do
    		local sPattern = "reference.features." .. w .. "@Example Module PC Options";
                    ... (then i did the logic i wanted to do for each link in here)
    And then later I used the sPattern variable to get the database node of the shortcut links that I was trying to receive and do the processing I wanted to do after that in that loop I left off on.
    Last edited by SieferSeesSomething; December 1st, 2024 at 08:22. Reason: added in some code from my example solution

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 Product Walkthrough Playlist

Log in

Log in