-
November 30th, 2024, 02:28 #1
- Join Date
- Mar 2020
- Posts
- 61
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>
Code:Debug.console("sRecord:",sRecord);
Code:s'sRecord:' | s'reference.races.customrace@Example Module PC Options'
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.
-
December 1st, 2024, 02:09 #2
you will need to use one or more of the various lua string match functions to further whittle your result down.
-
December 1st, 2024, 08:14 #3
- Join Date
- Mar 2020
- Posts
- 61
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)
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