PDA

View Full Version : XML Assistance in Savage Worlds Module Creation



GunbunnyFuFu
October 17th, 2016, 18:29
Good day! Once more I come to the well of knowledge in order to figure out how to do something in the XML. Working on my Savage Rifts module...got most of it laid out correctly, save some Gear entries. I'd like to have a reference page for each type of gear, ie Body Armor. On this reference page would be links to the various types of body armor in the reference.bodyarmor section that when clicked brings up the reference text for that piece of body armor. Here's what I have so far (this appears in <library>):


<chapter_201_bodyarmor>
<librarylink type="windowreference">
<class>sw_referencetextwide</class>
<recordname>..</recordname>
</librarylink>
<name type="string">**Body Armor</name>
<text type="formattedtext">
<p>Aside from minor electronics, most of these suits of armor do not have powered enhancements. All cover all locations and many have Full Environmental Protection, which includes fully sealed systems; self contained breathing; immunity to temperature extremes, radiation, vacuum, poisons, and disease; and other self-regulating life support systems. Unless otherwise stated, all have basic (five mile range) communications and light sensitive visors or eye lenses (offset illumination penalties by 2 and provide +2 to resist blinding attacks).</p>
<p>Each suit of body armor also has a Strength Minimum listed. For every die type the wearer has under the minimum, he suffers a −1 to all Agility and Agility-linked skill rolls, as well as −1 to his Pace. In Savage Rifts®, this penalty also applies to Arcane skill rolls (including psionics).</p>
<p><b>Embedded Toughness:</b> To reflect the advanced technology used to construct Rifts Earth armor, many suits of body armor also provide additional points of Toughness. This is a huge enhancement, in light of the fact that Armor Piercing has no effect on Toughness.</p>
</text>
</chapter_201_bodyarmor>

Pointers on how to do that? It seems rather easy, but after looking at the code for hours today, my brains a bit muddled. I was thinking it'd be a simple linklist, but not having any luck with that.

Thanks for any insight in advance!
GB

Talyn
October 17th, 2016, 20:04
Someone will probably beat me to the punch. I'm about to hop a flight home from work so if no one else answers this in the next few hours, I'll look at it after dinner when I'm home.

GunbunnyFuFu
October 17th, 2016, 20:34
Thanks Talyn!

Talyn
October 18th, 2016, 00:32
Ok, I brought up several windows, which type are you asking about?

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=15742&stc=1&d=1476746334

From your description, it sounds like you're wanting the big list of gear right? Then you click an item and it brings up the smaller window? Plus you can drag the item into a character's inventory?

If so, that particular window is a "reference_categorisedlist" class. In the screenshot I used, that's the normal gear/equipment which for the upcoming 3.2 version of Fantasy Grounds, they want that contained in <mundaneitems> for Savage Worlds, per the Data Structure & Best Practices (https://www.fantasygrounds.com/wiki/index.php/Data_Structure_Overview_and_Best_Practices) article. On that note, be sure you're testing on 3.2 as some of the sorting gets finicky if you use categories it doesn't like, whereas 3.17 doesn't give a damn what you call anything.

So in my Library, I call a "reference_categorisedlist" class, and point it to the "reference.lists.mundaneitems" recordname.
In that <lists> section, that's where you build how the window looks, the titles of the category columns, width, etc. and one of the tags there specifies <itemclass type="string">item</itemclass> which tells the list window to use the "item" window class when you click on any of the links, which is the smaller window you see there detailing the grappling hook in my screenshot.

The individual items themselves are contained in reference.mundaneitems with all their pertinent info.

That what you were after or something else?

15742

GunbunnyFuFu
October 18th, 2016, 01:11
The way I envision it is that in the library there is an entry called "Quick Lists", much like every other Savage Worlds setting I've seen. Of course, this module has new edges, hindrances, etc. Also there would be a link to gear there. You click the link, that calls a window that flavor text about gear in general, and links to each specific kind (ie Body Armor, Power Armor, Robot Armor, etc.). Clicking any of these links will bring up yet another window with fluff information on the specific category of gear (IE standard body armor has a 5 km radio, etc.). Under that bit of fluff is the links to the body armor (for example, Juicer Plate). Each one of those points at a the appropriate reference.list.bodyarmor recordname, and each one of those links can be drug to a character sheet. Clicking on the link will bring up the small record that is specific to that body armor, weight, etc.

It could be that I'm going about this all wrong and convoluted. In the Savage Rifts setting, there is a lot of information along with the lists of items. I'll post a screenshot of the module to date when I get home so that the picture can do a much better job of describing it!


Thanks,
GB

Talyn
October 18th, 2016, 01:43
Oh, so this thing:

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=15743&stc=1&d=1476750631

That window class is "sw_referenceindex" and you just build an <index> then list each item as a <link>. Personally, I'm not a fan of that class (or if I'm being honest, the majority of the sw_* classes) but several projects in the past have used them because they're there I guess. But whatever works for you, since Rifts will have to be a personal project -- there's no license for an official FG version of it unfortunately so enjoy what you're building, that probably took awhile! :)

If it helps, unzip the SW ruleset somewhere outside FG. The SW classes are in /ref/ref_basicclasses.xml and a couple others in /ref/ref_swclasses.xml plus don't forget the CoreRPG classes that Savage Worlds is overlayed upon.

15743

GunbunnyFuFu
October 18th, 2016, 03:31
Thanks for the information, Talyn! I had no idea where to look for the classes. I assume any of the CoreRPG classes will work as well? I'll post those screenies shortly..still buried at work. The portion that I'm working on will link to those same entries on the table displayed above, but will have additional text "fluff" on them. I can't put additional fluff on those sw_referenceindex classes, correct (ie no <text type="formattedtext"> or <description type="formattedtext">. I'm hoping that SW class files answers the question of which of those two types of XML entries work on which classes...sometimes one works, sometimes the other. I think it's due to the specific Window Class being called...

Talyn
October 18th, 2016, 03:55
Yes, all CoreRPG window classes work in Savage Worlds (and every other ruleset (most of them)) which are overlayed on CoreRPG.

Here's an edited snippet of the window above (it's the Sci-Fi Companion by the way):



<chapter_010_quicklinks>
<librarylink type="windowreference">
<class>sw_referenceindex</class>
<recordname>..</recordname>
</librarylink>
<name type="string">Quick Links</name>
<index>
<_06_armor>
<listlink type="windowreference">
<class>reference_categorisedlist</class>
<recordname>reference.lists.armor@Science Fiction Companion</recordname>
</listlink>
<name type="string">Armor</name>
</_06_armor>
</index>
</chapter_010_quicklinks>


So in that module, the author built the entire list of items for the Quick Links (all the edges, hindrances, new gear, etc.) all into that library entry. That's what the <recordname>..</recordname> means.

I chose the armor link since you were talking about armor for Rifts. As you can see, clicking that opens the reference_categorisedlist class I was talking about above, which is a sorted list of all the items like the gear in my Lankhmar screenshot. The reference.lists.armor defines how that list looks—the column names, etc. while within that list header there's <source type="string">reference.armor@Science Fiction Companion</source> which tells the entire list where to fill itself with data from. It sounds complicated but it's pretty simple to understand once you dig in and play with it a couple times.

I'd suggest unzipping some of the settings you own and looking at their code. Now, some of the code is a little older and is a little inefficient though it still works fine obviously. If nothing else, it's good to learn from and that's exactly how I got my start learning (and trust me, I'm still learning!). Also, <linklist> is no longer necessary, just a simple <link> will do the trick.

GunbunnyFuFu
October 18th, 2016, 04:52
I had purchased the Interface Zero and Nemezis settings, however, they're not showing up in the Modules. I'm assuming they're encrypted within the Content Vault...sadly, that's the only reason I purchased them was to tear them apart and see how they were constructed...

GunbunnyFuFu
October 18th, 2016, 06:23
OK..this is what I have:
15746
You can see my library (Work in Progress) on the left hand side for Savage Rifts. Upon clicking the Gear entry in the library, this opens up the Gear Reference box. No issues there. Now then, when clicking on the Body Armor entry to the left in the Library, the Body Armor Reference text is pulled up. What I'd like to do is beneath the "Embedded Toughness" bit on the Body Armor Reference Text is to put links to each of the individual body armor types (example, juicer plate). When clicking the link, it'd bring up the appropriate entry in reference.lists.bodyarmor.

You mentioned "reference_categorisedlist" class. Does this particular class allow you to add formatted text to it? If so, that would work exactly how I need it to.

Thanks again for your help Talyn!

GB

GunbunnyFuFu
October 18th, 2016, 06:33
In the following graphic, you see the reference_categorizedlist class for the SciFi Companion's Power Armor. I've drawn a blue line over it, indicating where ideally I'd like my text to go. Is it possible to insert formatted text at this location on this particular class?

15747

Talyn
October 18th, 2016, 12:44
I had purchased the Interface Zero and Nemezis settings, however, they're not showing up in the Modules. I'm assuming they're encrypted within the Content Vault...sadly, that's the only reason I purchased them was to tear them apart and see how they were constructed...

Yeah, sadly those are encrypted due to the specific publishing license. :( None of the other SW settings (that I own anyway) are encrypted.

Talyn
October 18th, 2016, 13:24
In the following graphic, you see the reference_categorizedlist class for the SciFi Companion's Power Armor. I've drawn a blue line over it, indicating where ideally I'd like my text to go. Is it possible to insert formatted text at this location on this particular class?

15747

Not at that location. The way the class is built, it renders the <name type="string">Power Armor</name> as Header text, centered. On that class, you can do a <notes type="formattedtext">blahblahblah</notes> and that will appear at the bottom of the window, underneath the search bar. You can see this on the Sci-Fi Companion if you click Robotic Modifications which brings up a text table but click the Table: Robotic Modifications link at the top of the page to show the actual reference_categorisedlist for them.

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=15749&stc=1&d=1476793568

15749

GunbunnyFuFu
October 18th, 2016, 13:45
Talyn,

Thanks again. So it looks like I'll have to use a referencetext window..they do support links. Would that be a simple <linklist> followed by the necessary <links>, or is an <index> needed?

GB

Talyn
October 18th, 2016, 13:56
Or you can use the sw_referenceindex class, which supports both formatted text and the links. In the Sci-Fi Companion, click the Characters entry to see that in action.

One way to tell the sw_referenceindex is being used is links are spaced apart more than they are in a referencetext or other window class. If you notice in the Edges windows, it auto-detects (based on the (Major/Minor) labels) when edges are displayed and offers the little sorting dropmenu at the bottom.

GunbunnyFuFu
October 18th, 2016, 14:07
Talyn,

Finally figured it out with your assistance! Thanks! I used a referencetext class, and then added the linklist, using link class="armor" and it came out exactly how I needed. You help has been much appreciated!!!

GB

GunbunnyFuFu
October 18th, 2016, 14:12
This brings up another question...in the character sheet, armor section, we have the following:

15750

Is there a way to add a column to this? Next to Protection, can we add a column for Toughness (some armor in Rifts increases the user's toughness). Would this be an extension to handle that?

GB

Talyn
October 18th, 2016, 14:19
Yes, you will have to write a quick extension for that. Luckily, the Savage Worlds ruleset has an API (https://www.fantasygrounds.com/forums/showthread.php?26363-Savage-Worlds-API&highlight=Savage+worlds+API) of sorts for that type of thing. :)

For example, Lankhmar has a Corruption attribute. So part of my extension has the following to add it:



function onCharAdded(nodeSource, nodeChar)
DerivedStatManager.registerDerivedStat("Corruption", "Corr", "corruption", "derivedstat_default", {charsheet=true, minisheet=true, npc=true})
end

GunbunnyFuFu
October 18th, 2016, 14:24
Talyn,

Thanks! I've never even looked at making an extension yet, so this could be interesting! I'll add it to the to-do list, saving it for when I get the raw data entered in the setting.

GB

Talyn
October 18th, 2016, 14:27
Fixed my reply, that version of the extension loaded Corruption into the Setting Mods frame. The edited reply puts it on the character sheet itself.

GunbunnyFuFu
October 18th, 2016, 17:15
Got all the armors entered in, however, at ID-0010 I started to get this error: Script Error: [string "common/scripts/template_WindowList.lua"]:161: copyNode: Unable to create destination node, or destination node can not be the same as or a child of the source node.

Not sure what I did wrong. I've included the XML for it...I simply copied/pasted each ID segment, changing the tag and data within it. (IE copied id-0009, pasted it, changed the tag to id-0010, and changed the relevant data).


<id-0010>
<name type="string">Ley Line Walker Light Armor (TW)</name>
<group type='string'>Body Armor</group>
<catname type="string">Armor</catname>
<areaprotected type="string">All</areaprotected>
<protection type="number">3</protection>
<arweight type="number">4</arweight>
<cost type="string">$9,000</cost>
<toughness type="number"></toughness>
<strmin type="string"></strmin>
<armornotes type="string"></armornotes>
<notes type="string"></notes>
<text type="formattedtext"><p>Constructed from natural and magically engineered materials, this armor was originally designed for Ley Line Walkers (though anyone can wear it) so they could conceal it beneath their traditional robes. These suits provide 3 Armor; though they are not fully covering, they come with a breath mask and magical filter system that provides +4 to Vigor rolls against airborne toxins and diseases. The breathing system requires the wearer be magically or psionically active in order to function (though it costs no actual PPE or ISP). (4 lb, 9,000 credits)</p>
</text>
</id-0010>
<id-0011>
<name type="string">Ley Line Walker Medium Armor (TW)</name>
<group type='string'>Body Armor</group>
<catname type="string">Armor</catname>
<areaprotected type="string">All</areaprotected>
<protection type="number">5</protection>
<arweight type="number">8</arweight>
<cost type="string">$12,000</cost>
<toughness type="number"></toughness>
<strmin type="string"></strmin>
<armornotes type="string"></armornotes>
<notes type="string"></notes>
<text type="formattedtext"><p>A heavier suit for those Walkers and other casters wanting a bit more protection at the cost of being a bit more obvious. The Armor value of this suit is 5, and it provides the same mask-and-filter system as the Light version. Its bulk is a bit harder to conceal (−2 on such efforts). Filter system requires an arcane background but no Power Point cost to maintain. (8 lb, 12,000 credits)</p>


GB

Talyn
October 18th, 2016, 17:18
Look at your <group type='string'> it should be ... "string" with double quotes.

Trenloe
October 18th, 2016, 17:27
Yes, you will have to write a quick extension for that. Luckily, the Savage Worlds ruleset has an API (https://www.fantasygrounds.com/forums/showthread.php?26363-Savage-Worlds-API&highlight=Savage+worlds+API) of sorts for that type of thing. :)

For example, Lankhmar has a Corruption attribute. So part of my extension has the following to add it:



function onCharAdded(nodeSource, nodeChar)
DerivedStatManager.registerDerivedStat("Corruption", "Corr", "corruption", "derivedstat_default", {charsheet=true, minisheet=true, npc=true})
end

This is a derived stat specific to a character.

GunbunnyFuFu is wanting to add a "Toughness" column to the armor list in the character sheet (post #17 above), not a new derived stat to the character.

@GunbunnyFuFu You would need to write a small extension that added "Toughness" to the armor list in the character sheet. You'd also need to adjust the relevant armor windowclass XML entries within the ruleset so that the armor details could store the toughness adjustment as well.

If you wanted to go all the way with this, you could write some additional code that adds the armor "toughness" rating to the list of additional toughness entries available to the PC when you double click on the Toughness stat (similar to the armor value available in the list when you double click on the little shield to the bottom left of the PC toughness stat).

This would all need to be done within an extension.

Talyn
October 18th, 2016, 17:31
Ah, I totally misunderstood then. Thanks, Trenloe!

GunbunnyFuFu
October 18th, 2016, 17:45
Made the change, with no change in error message. Thanks, though, I didn't change the single quote versus double quote..I looked right at it as well, and it just never registered!

GunbunnyFuFu
October 18th, 2016, 17:49
This is a derived stat specific to a character.

GunbunnyFuFu is wanting to add a "Toughness" column to the armor list in the character sheet (post #17 above), not a new derived stat to the character.

@GunbunnyFuFu You would need to write a small extension that added "Toughness" to the armor list in the character sheet. You'd also need to adjust the relevant armor windowclass XML entries within the ruleset so that the armor details could store the toughness adjustment as well.

If you wanted to go all the way with this, you could write some additional code that adds the armor "toughness" rating to the list of additional toughness entries available to the PC when you double click on the Toughness stat (similar to the armor value available in the list when you double click on the little shield to the bottom left of the PC toughness stat).

This would all need to be done within an extension.

Correct...I'd add the Toughness stat as well as the Strength Minimum stat to the Armor List, as well as the Armor reference window. I'll need to find a good primer on extensions, as while I've played with XML some, I've never played with LUA (eyes the Beginning LUA Programming book on his bookshelf). Now is as good time as any to start. Can either of you suggest a good place to start on building said extension?

Thanks for all your help so far..it has been invaluable!

GB

Trenloe
October 18th, 2016, 18:31
Can either of you suggest a good place to start on building said extension?
Some general reference stuff here: https://www.fantasygrounds.com/forums/showthread.php?20651-Modifying-the-CoreRPG-ruleset

Specific info on an extension here: https://www.fantasygrounds.com/modguide/extensions.xcp

I've attached an example extension that gets you started. I've quickly added toughness to: Armor record, Table heading in charsheet -> Inventory -> Armor, and the row data in that table.

Note: This will work with the base Savage Worlds ruleset. It won't work with the Science Fiction companion, as that changes the armor data too. If you're using the Science Fiction companion then the XML in this text extension will need to be based on XML from the SciFi Companion extension.

GunbunnyFuFu
October 18th, 2016, 18:49
Thanks Trenloe! I'll take a look at this stuff, and look at doing this for the Sci-Fi Companion, as Rifts uses stuff from there.

GB

Trenloe
October 18th, 2016, 18:59
ThI'll take a look at this stuff, and look at doing this for the Sci-Fi Companion, as Rifts uses stuff from there.
The main issue you'll have here is that they are two extensions, and you want to make sure your changes don't get overridden by the SciFi companion. I specifically put a <loadorder> = 99 property in the test extension I provided. This will make it load after the SciFi companion extension (which has loadorder = 10). So you should be fine taking the updated_record_armor.xml from the SciFi companion and updating that - as long as you keep that loadorder in your extension to be greater than 10.

I would then also recommend that you make your extension dependant on the SciFi extension (just in case you forget to load it). See the <dependency> tag here: https://www.fantasygrounds.com/refdoc/properties.xcp

Mortar
October 18th, 2016, 23:56
Yeah, sadly those are encrypted due to the specific publishing license. :( None of the other SW settings (that I own anyway) are encrypted.

All the new stuff released regardless of rules set is encrypted. I imagine as older stuff gets updated and pushed out it will end up encrypted as well.

Gunny,

You can also save yourself some coding and go this route as well (copy/pasted from Weird Wars Rome):


<chapter_001_artwork>
<librarylink type="windowreference">
<class>sw_referencetext</class>
<recordname>..</recordname>
</librarylink>
<name type="string">* *Artwork</name>
<text type="formattedtext">
<p></p>
<link class="imagewindow" recordname="wwrimage.id-000">Front Cover</link>
<link class="imagewindow" recordname="wwrimage.id-001">Image 1</link>
<link class="imagewindow" recordname="wwrimage.id-002">Image 2</link>
<link class="imagewindow" recordname="wwrimage.id-003">Image 3</link>
<link class="imagewindow" recordname="wwrimage.id-004">Image 4</link>
<link class="imagewindow" recordname="wwrimage.id-005">Image 5</link>
<link class="imagewindow" recordname="wwrimage.id-006">Image 6</link>
<link class="imagewindow" recordname="wwrimage.id-007">Image 7</link>
<link class="imagewindow" recordname="wwrimage.id-008">Image 8</link>
<link class="imagewindow" recordname="wwrimage.id-009">Image 9</link>
<link class="imagewindow" recordname="wwrimage.id-010">Image 10</link>
<link class="imagewindow" recordname="wwrimage.id-011">Image 11</link>
<link class="imagewindow" recordname="wwrimage.id-012">Image 12</link>
<link class="imagewindow" recordname="wwrimage.id-013">Rear Cover</link>
</text>
</chapter_001_artwork>

GunbunnyFuFu
October 19th, 2016, 04:06
Trenloe,

Thanks! I'll work on the extension as I can, but this gives me a great place to start.

Mortar,

The link classes are for images, correct? I'll be adding some images once I get game data entered in.

GB

Trenloe
October 19th, 2016, 04:09
The link classes are for images, correct? I'll be adding some images once I get game data entered in.
Yeah, but the theory can be applied to other FG elements. A good way for you to see what you can use is to create a few items (armor or whatever) in the campaign data lists, then create a new Story entry. Drag a few items to the story entry, so that a set of links are made for each item in the story. Then exit the campaign and have a look at the db.xml file for the campaign to see what the format of the links are. You can then use that format anywhere there is a formatted text control.

GunbunnyFuFu
October 19th, 2016, 04:24
Thanks Trenloe...that will be very, very handy moving forward!