• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

XPath Modding Explanation Thread

This is a large amount of information in these posts. I'll be working on a full, properly formed tutorial as we get access to A17 and we can really make the xpath system shine. I've listed some examples here, and we'll be posting a ton more xpath samples over the coming weeks, as we port the SDX modlets over to use the native hooks.

By all means, begin posting your comments, questions, or requests for clarity.

Since we now know that xpath support will be built-into the vanilla base game, and discussions earlier were getting a bit confusing, I've decided to make a new thread to try to demystify xpath and what it'll mean for mods and modders going forward in A17. The information in this thread has been pieced together from forum and discord discussions. They may not be 100% accurate, but I will update this thread when we know the full implementation.

XPath is a way of adding, changing, or removing XML lines and nodes, without directly editing the XML files. It allows you to apply patches to the XML files without manually editing the vanilla XML files.

SDX has had partial support for this since its initial release, and a lot of the SDX Modlets are already written this way. We will be using some of the SDX's xpath as examples in this thread, but SDX is not required to do this in A17 and onwards.

I believe in using examples to explain concept, so in the next few posts, you'll see a mixture of explanation, along with sample xpath code.

The following Mod structure is expected for A17 and beyond:

Code:
Mods/
   <ModName>/
       Config/
       UIAtlases/ItemIconAtlas/
       ModInfo.xml

   <ModName2>/
       Config/
       ModInfo.xml
You will be able to have multiple mods loaded, and loading will occur as long as the ModInfo.xml exists. This is unchanged from what we've been doing doing with other alphas, with the exception of the Config folder.

This Config folder will support loading XML files, written using xpath, in the following folder structure:

Code:
Config/entityclasses.xml
Config/gamestages.xml
Config/items.xml
The files in the Config folder will not be a full copy of the vanilla file with your changes. Rather, it'll contain the changes you want done to the vanilla files. The files under the Config must match the vanilla file name. You cannot create an entityclasses2.xml file, and expect it to work. Any changes in the entityclasses.xml will have to be done in the same file. However, each mod can have its own entityclasses.xml.

During the game's initialization, it will perform the xpath merge in-memory only; no files will be actually be modified. This would allow us to remove mods we no longer want, without re-validating against steam, or previous copies of the xml. That's a big one. No more half merging of a mod, and not having it work, then trying to pull it back out.

What this means for us is that we'll be able to make a variety of smaller mods, which I've been calling modlets, which can add, remove and change smaller pieces of the game. They can be used together, or they could be added to an overhaul mod, in order to style your game play easier.

These modlets would also exists outside of the Data/Config folder, so if you have made direct XML changes in your Alpha 17.1 Data/Config files, and Steam updated the game to 17.2, you would have lost your changes, or would have to re-merge them in. We've all been there before. But if they existed as modlets, under the Mods folder, they would be safe. And as long as your xpath is still valid to the new XML, it should load up with no additional work on your part.

If we could use xyth's JunkItems modlet, which adds random, scrappable junk items to loot containers, and add them to Valmod Overhaul. Likewise, if Valmod Overhaul did not have the No Ammo modlet (which gives you the ability to unload a gun and get its bullets back without disassembling it), you could drop the NoAmmo modlet into your Mods folder. Headshots only? Want to increase stack sizes? Same deal.

With a properly constructed modlet, we'll be able to piece together new play styles for people to enjoy and share. A modder working on a large overhaul won't have to duplicate work. If they wanted to include the No Ammo mod, they wouldn't have to code it themselves, letting them focus on the bits that make their mod really unique.

Let's get started on your journey...

 
Last edited by a moderator:
I love modlets, because you don't have to overwrite the vanilla files. But I can't use these modlets in my own mod with the mod launcher because the launcher replaces all vanilla files in Data/Config with the modlet xml files inside the mod folder. That's weird. Is there any solution?

 
I love modlets, because you don't have to overwrite the vanilla files. But I can't use these modlets in my own mod with the mod launcher because the launcher replaces all vanilla files in Data/Config with the modlet xml files inside the mod folder. That's weird. Is there any solution?
The Mod Launcher isn't ready yet for modlets, but support is coming. Right now I'm just watching to see how people are setting things up.

If you create a folder called "Mods", then place all the modlets in there, the launcher should copy the Mods folder in the correct place.

TempMods/Mods/<modname>

 
can someone tell me why this doesnt work

im not getting any errors but it is not lowering the volume of the chainsaw

Code:
<configs>
<set xpath="/Sounds/SoundDataNode[@name='chainsaw_fire_start']/Noise/@volume">3</set>
<set xpath="/Sounds/SoundDataNode[@name='chainsaw_fire_rev']/Noise/@volume">3</set>
</configs>
 
never mind

seems you cant edit the volume of sounds through the xml

that setting only changes the volume that the zeds hear not what comes out of the speakers

damn I need to lower that volume

 
ok, didn't see it, so.... where do you find the item ID number? items.xml says it's generated internally on loading the game.
IDs in the items.xml and blocks.xml aren't a thing anymore. We can have about 32,000 unique items and 32,000 unique blocks now. Be sure your block name is unique.

 
IDs in the items.xml and blocks.xml aren't a thing anymore. We can have about 32,000 unique items and 32,000 unique blocks now. Be sure your block name is unique.
I was basing the question on your code snippets at the start.

I want to modify the damage for some weapons and ammo, and I *think* I can do that without item id.

(I know there were there in 16, but noticed nope, can't find'em and saw the line at the bottom of the file)

Oh well, if it asplodes, then back to the drawing board. :)

thanks.

 
I was basing the question on your code snippets at the start.
I want to modify the damage for some weapons and ammo, and I *think* I can do that without item id.

(I know there were there in 16, but noticed nope, can't find'em and saw the line at the bottom of the file)

Oh well, if it asplodes, then back to the drawing board. :)

thanks.
If you show us an example, we can help get you started

 
Here's a question:

Code:
<recipe name="foodGrilledMeat" count="1" craft_area="campfire" craft_tool="toolCookingGrill" tags="learnable">
<ingredient name="foodRawMeat" count="5"/>
</recipe>
I only want to remove

Code:
tags="learnable"
Is it possible? If I set it to "0" it still unlocks the recipe, but... Maybe there are cases where I can't do that. And it's kinda ugly.

Of course I looked for a solution already, but didn't find anything.

 
Could someone help me add infinite bullets

all weapons by XPath "modlet": 02,47-tranquilidade:

gunPistol

* gunSMG5

*gun44Magnum

*gunPumpShotgun

*gunHuntingRifle

*gunAK47

*gunCrossbow

Would have like? :upset:

 
Here's a question:

Code:
<recipe name="foodGrilledMeat" count="1" craft_area="campfire" craft_tool="toolCookingGrill" tags="learnable">
<ingredient name="foodRawMeat" count="5"/>
</recipe>
I only want to remove

Code:
tags="learnable"
Is it possible? If I set it to "0" it still unlocks the recipe, but... Maybe there are cases where I can't do that. And it's kinda ugly.

Of course I looked for a solution already, but didn't find anything.
I've never tried; have you tried <remove xpath="/recipes/recipe[@name=foodGrilledMeat]/@tags" /> ?

 
Could someone help me add infinite bulletsall weapons by XPath "modlet": 02,47-tranquilidade:

gunPistol

* gunSMG5

*gun44Magnum

*gunPumpShotgun

*gunHuntingRifle

*gunAK47

*gunCrossbow

Would have like? :upset:

Code:
<append xpath="/recipes/recipe[@name='gunSMG5']/property[@class='Action1']" >
      <property name="Infinite_ammo" value="true" />
</append>
It'd look like that, for each gun you want.

 
<item name="gunMR10">

<effect_group name="Base Effects">

<passive_effect name="EntityDamage" operation="perc_add" value="8.0"/>

8 is what I changed it to in items,

edit:

<set xpath="/items/item[@name=MR10]/effect_group[@name=Base Effects]/passive_effect[@name=EntityDamage][@operation=perc_add]/@value">.25,8.0</set>

I think that would do it (copied format from another thread)

 
Last edited by a moderator:
No sorry, there's no math operation in the current xpath system. xpath is just a method of finding stuff in the XML. The game uses the xpath to make the appropriate changes.
I kinda figured but wanted to double check. Haven't used XPATH yet (I'm WAY behind the times in languages) so I'm getting the hang of it. Guess I have a lot of copy/pasting to do. Thanks!

 
@sphereii - I don't recall seeing a possible answer to something I have been wondering with the Mods & Modlet system.

Question is Localization files. If we are adding in new blocks and items (I have about 4000+ to be added in now), How do we handle the Localization.txt and Quest files? Do we just add them to our Mods in the Configs folder? Or is there a way to Amend them using this new style?

I am sure I cannot be the only one who is wondering this. Being most of this stuff can be pushed via the dedicated server. I know some stuff will require client side downloads if we have additional Icons or Resource files. I know with SDX it would just amend to them and that was awesome! However with this new method I do like it more BUT with some of the SDX Mods I loved that altered the DLL because of scripts and what not (like changing the BloodMoonNight scripts to a different day then every 7).

How do we handle that kind of stuff now?

Thanks this was just driving me crazy lol

 
@sphereii - I don't recall seeing a possible answer to something I have been wondering with the Mods & Modlet system.
Question is Localization files. If we are adding in new blocks and items (I have about 4000+ to be added in now), How do we handle the Localization.txt and Quest files? Do we just add them to our Mods in the Configs folder? Or is there a way to Amend them using this new style?

I am sure I cannot be the only one who is wondering this. Being most of this stuff can be pushed via the dedicated server. I know some stuff will require client side downloads if we have additional Icons or Resource files. I know with SDX it would just amend to them and that was awesome! However with this new method I do like it more BUT with some of the SDX Mods I loved that altered the DLL because of scripts and what not (like changing the BloodMoonNight scripts to a different day then every 7).

How do we handle that kind of stuff now?

Thanks this was just driving me crazy lol
Localization isn't supported yet, but I think it's coming something in A17.* or A18. So we'll have an awkward period where we don't have a lot of flexibility with it.

Only the XML files from the Mods folder get pushed from the dedicated (localization doesn't either).

As for SDX, it will work along side with the Mods. You will still neet client side installs for any SDX mods, any mods that contain asset bundles, or custom icons. SDX can compile Scripts and PatchScripts into the DLL, and it also can handle the Localization merges, like it always has.

From a player perspective, they'll install the mods like they normally do: Copying a zip file with all the files in the right place.

xpath and modlets are an easier way for modders to create small patches and portable mods for others to enjoy that is also less maintenance for them.

 
ok, I am starting with stack sizes to learn. can someone break this down for me

this is just for feathers

<set xpath="/items/item[@name=resourceFeather]/property[@name=Stacknumber' and @value='5000]</set>

is this correct? to get a stack size of 5000

<set xpath="/items/item/property[@name=Stacknumber' and @value='500]/@value">512</set>

what is the @512 for?

 
Will there be a " X path" Mod Launcher?
Yes, a solution will be shown soon on how we can deal with modlets. Right now the modlets are a bit of a mess for distribution, but it's experimental, so it hasn't be a huge concern of mine.

However, a github/gitlab based solution, like we do with mods, will have hooks into this "modlet" launcher.

 
Yes, a solution will be shown soon on how we can deal with modlets. Right now the modlets are a bit of a mess for distribution, but it's experimental, so it hasn't be a huge concern of mine.
However, a github/gitlab based solution, like we do with mods, will have hooks into this "modlet" launcher.
I <3 you

 
Back
Top