• 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:
thanks man!

I thought Ive tried that, but maybe it didnt work because of a typo or something

edit: I guess I had a '/' at the end, to indicate its not inside recipe, who knows cant recall.

 
Last edited by a moderator:
Hi Sphereii

I've been working on some mods and got a few working but I'm having issues with this one and I'm wondering if you could help point out what I've done wrong please.

Here is my xpath:

https://pastebin.com/KukxTWSe

Ignore the custom block types I've added, my test launches on return errors with biomes.xml and the blocks have tested fine.

This is my first time trying to insert an entire sub-node within a node via xpath append and i'm unsure if it's the correct way, it's most likely the issue.

All my other appends that add entire new nodes work fine.

 
Hi SphereiiI've been working on some mods and got a few working but I'm having issues with this one and I'm wondering if you could help point out what I've done wrong please.

Here is my xpath:

https://pastebin.com/KukxTWSe

Ignore the custom block types I've added, my test launches on return errors with biomes.xml and the blocks have tested fine.

This is my first time trying to insert an entire sub-node within a node via xpath append and i'm unsure if it's the correct way, it's most likely the issue.

All my other appends that add entire new nodes work fine.
In notepad++, you can use XML Tools to pretty print your XML. Then you'd see your XML like this:

Code:
	<subbiome prob="0.1551">
		<!-- Ore Sub Biome: Copper -->
		<layers>
			<layer depth="4" blockname="terrSnow"/>
			<resource blockname="Gravel_Plus_Copper" prob="0.071" rwgGenerationType="all"/>
			<layer depth="3" blockname="terrDirt">
				<resource blockname="Gravel_Plus_Copper" prob="0.811" rwgGenerationType="all"/>
			</layer>
You can see your layer depth"4" blockname="terrSnow" closes it's layer. So that resource blockname is kind of just floating around.

 
In notepad++, you can use XML Tools to pretty print your XML. Then you'd see your XML like this:

Code:
	<subbiome prob="0.1551">
		<!-- Ore Sub Biome: Copper -->
		<layers>
			<layer depth="4" blockname="terrSnow"/>
			<resource blockname="Gravel_Plus_Copper" prob="0.071" rwgGenerationType="all"/>
			<layer depth="3" blockname="terrDirt">
				<resource blockname="Gravel_Plus_Copper" prob="0.811" rwgGenerationType="all"/>
			</layer>
You can see your layer depth"4" blockname="terrSnow" closes it's layer. So that resource blockname is kind of just floating around.
Yeah I know, that's how all the default sub-biomes are in the defualt A17b209 biomes.xml right now. It's not the cause of the issue.

What I am asking is, does my xpath append put these sub-biome nodes in the correct place of the biomes.xml?

Code:
<append xpath="/biomes/biome[@name='snow']">
 
Yeah I know, that's how all the default sub-biomes are in the defualt A17b209 biomes.xml right now. It's not the cause of the issue.What I am asking is, does my xpath append put these sub-biome nodes in the correct place of the biomes.xml?

Code:
<append xpath="/biomes/biome[@name='snow']">
You are missing the top level /worldgeneration xpath="/worldgeneration/biomes/biome[@name=snow]

 
when you say Mods you mean mods in the "mod" folder correct?

what forum do I check to add an item to A17? example I want to add a bike part or bike mod that includes new graphics. would that be possible?

example maybe I want a mod to add a rocket launcher or new colored parts.

 
Does anyone know if you can xpath into the Prefabs folder and change stuff in the xml files? Like is it possible?
No, unfortunately not. We are hoping to be able to load prefabs from the Mod folder eventually.

What were you trying to do in the prefab xml?

 
No, unfortunately not. We are hoping to be able to load prefabs from the Mod folder eventually.
What were you trying to do in the prefab xml?
Ah ■■■■ :/ Yeah one can only hope for that added functionality.

I was trying to change what zones the vanilla prefabs can spawn in, a workaround to temp add back in all the larger buildings.

Atleast I was trying to do it through xpath.

 
I'm trying to increase the probability of commonBooks spawning in certain containers. My xpath:

<loot>

<set xpath="/lootcontainers/lootcontainer[@id=14]/item[@group=books]/@prob=">0.4</set>

</loot>

I keep getting errors on trying to load the game. Before I grab my output log and all that, can someone just check I haven't made any silly errors? It looks like it should work but isn't.

 
I'm trying to increase the probability of commonBooks spawning in certain containers. My xpath:
<loot>

<set xpath="/lootcontainers/lootcontainer[@id=14]/item[@group=books]/@prob=">0.4</set>

</loot>

I keep getting errors on trying to load the game. Before I grab my output log and all that, can someone just check I haven't made any silly errors? It looks like it should work but isn't.

Remove the = after @prob and you should be good =)

Code:
[color=#DCDCD2]<set xpath="/lootcontainers/lootcontainer[@id='14']/item[@group='books']/@prob">0.4</set>[/color]
 
Remove the = after @prob and you should be good =)
Code:
[color=#DCDCD2]<set xpath="/lootcontainers/lootcontainer[@id='14']/item[@group='books']/@prob">0.4</set>[/color]
Well, starts without errors now at least. Thank you. I haven't noticed if it has made a difference in game yet, but we'll see.

 
Well seems like if I try and do any kind of append to entityclasses.xml as in adding in a new entity_class I get this error.

WRN XML patch for "entityclasses.xml" from mod "FastBurst Mod" did not apply: <append xpath="/entityclasses"

Example I tried to add this just to see:

Code:
<append xpath="entityclasses">
<entity_class name="zombieStripperRadiated" extends="zombieStripper">
	<property name="Tags" value="zombie,walker,feral"/>
	<property name="Mesh" value="Zombies/zombieStandardStripperRagdoll"/>
	<property name="ReplaceMaterial1" value="entities/zombies/materials/feral_eye"/>

	<!-- Gameplay -->
	<property name="MoveSpeedAggro" value=".5, 1.35"/>

	<property name="HandItem" value="meleeHandZombieStripperFeral"/>

	<property name="ExperienceGain" value="700"/> <!-- XP grunt feral -->
	<property name="LootDropProb" value=".03"/> <!-- Feral -->
	<effect_group name="Base Effects">
		<passive_effect name="HealthMax" operation="base_set" value="237"/>
		<passive_effect name="HealthMax" operation="perc_set" value="1"/> <!-- Zombie HP scale -->
		<passive_effect name="EntityDamage" operation="perc_add" value="0"/> <!-- Feral damage -->
	</effect_group>
</entity_class>
</append>
and I get that error immediately. I can do other appends that change values no problem. BUT, if I try and add any new entity_class it gives that error and doesn't apply them? Anyone know why or a work around for this or is this just not possible with the new Mod System?

 
Hi guys :) i'm hitting a wall after trying over hours to make my progressions.xml , Spawning.xml changes and loot.xml working with the xpath.... Hope someone could help me to make them working right...

Progression.xml

https://pastebin.com/2Q7Wbc8q

would to add my new Attribute, Skills and Perks, also want to edit 2 Values like Exp_to_level and experience_multiplier

Loot.xml

https://pastebin.com/ifcbK9gi

Looks like the line in loot like "<append xpath="loot/lootcontainers/lootcontainer" aren't right but its loot.xml to <lootcontainers> node and to another <lootcontainer name="AnyContainerName">

at spawning.xml:

<configs>


<set xpath="/spawning/biome[@name=city]/spawn[@name=maxcount]/@value">6</set>



</configs>


don't work^^ .....

Error Screen:

Error 3.jpg

Imgur Screenshot

 
Last edited by a moderator:
Back
Top