• 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:
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:

View attachment 26385

Imgur Screenshot
loot.xml:

Your append for it should be <append xpath="/lootcontainers/lootcontainer[@id=19]". The first part of the xpath is the root node of the XML, not the file name.

Pogression.xml:

You are trying to adjust the level using the @name='exp_to_leve']. However, the line is:

Code:
<level max_level="300" exp_to_level="9545" experience_multiplier="1.0149" skill_points_per_level="1">
Your xpath would be: <set xpath="/progression/level/@max_level">9500</set>

 
Last edited by a moderator:
I fixed loot by my self xD but tyvm...

got another decent issue with loot.xml.

would to add the (count="XYZ") tag to some items and change the value too. but i dont know how this works^^

ERROR TEXT LINK

I Trying this one:

<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkJarEmpty]/@count">1.5</set>


<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkJarBoiledWater]/@count">1</set>



<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkJarBeer]/@count">0.75</set>



<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkCanMegaCrush]/@count">0.2</set>


but its not the right one :x

 
I fixed loot by my self xD but tyvm...got another decent issue with loot.xml.

would to add the (count="XYZ") tag to some items and change the value too. but i dont know how this works^^

ERROR TEXT LINK

I Trying this one:

<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkJarEmpty]/@count">1.5</set>


<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkJarBoiledWater]/@count">1</set>



<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkJarBeer]/@count">0.75</set>



<set xpath="/lootcontainers/lootgroup[@name=beverages]/item[@name=drinkCanMegaCrush]/@count">0.2</set>


but its not the right one :x
There's no existing count value on that for you to change. You'd need to use setattribute to create a new one:

Code:
<setattribute xpath="/lootcontainers/lootgroup[@name='beverages']/item[@name='drinkJarEmpty']/@count">1.5</setattribute >
<setattribute xpath="/lootcontainers/lootgroup[@name='beverages']/item[@name='drinkJarBoiledWater']/@count">1</setattribute >
<setattribute xpath="/lootcontainers/lootgroup[@name='beverages']/item[@name='drinkJarBeer']/@count">0.75</setattribute >
<setattribute xpath="/lootcontainers/lootgroup[@name='beverages']/item[@name='drinkCanMegaCrush']/@count">0.2</setattribute >
 
Ty mate :)

only 2 things left now . ..

1. need to add my own progression Attribute (luck), Skills and Perks of it.

Progression Attribute+Skills+Perks

2. Modifing spawnings

Original:

<biome name="city">


<spawn maxcount="3" respawndelay="1" time="Day" entitygroup="ZombiesAll" />



<spawn maxcount="5" respawndelay="1" time="Night" entitygroup="ZombiesNight" />



<spawn maxcount="1" respawndelay="1" time="Any" entitygroup="ZombieDogGroup" />



</biome>


WHAT I DID:

<configs>

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

</configs>

WHAT I WANT

<biome name="city">


<spawn maxcount="from 3 to 6" respawndelay="1" time="Day" entitygroup="ZombiesAll" />



</biome>


 
Ty mate :)
only 2 things left now . ..

1. need to add my own progression Attribute (luck), Skills and Perks of it.

Progression Attribute+Skills+Perks

2. Modifing spawnings

Original:

<biome name="city">


<spawn maxcount="3" respawndelay="1" time="Day" entitygroup="ZombiesAll" />



<spawn maxcount="5" respawndelay="1" time="Night" entitygroup="ZombiesNight" />



<spawn maxcount="1" respawndelay="1" time="Any" entitygroup="ZombieDogGroup" />



</biome>


WHAT I DID:

<configs>

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

</configs>

WHAT I WANT

<biome name="city">


<spawn maxcount="from 3 to 6" respawndelay="1" time="Day" entitygroup="ZombiesAll" />



</biome>
I've noticed this in a few of your xpath, so I just want to clarify the @value meaning.

That @value means "attribute called value", and @name means "attribute called name". In your spawnings, you are using @name='city' correctly, as name="city" is valid in the XML node. However, you go on to use spawn[@name=maxcount]. There's no attribute call name in the spawn line.

The conditions in the [ ] are there to help you isolate which line you want to change, and can be any attribute on the line that is somewhat unique.

The following lines would work, and both will adjust the ZombiesAll line.

Code:
<set xpath="/spawning/biome[@name='city']/spawn[@entitygroup='ZombiesAll']/@maxcount">6</set>
<set xpath="/spawning/biome[@name='city']/spawn[@time='Day']/@maxcount">6</set>
 
Ty for the Explanation.

its absolutely new to me, an crushing my head ... Did my best to learning by doing. but i had to understandt the logic behind the commandlines :)

and both commands of you make sense on hiw own way....

than are just the Progression left :)

 
Ty for the Explanation. its absolutely new to me, an crushing my head ... Did my best to learning by doing. but i had to understandt the logic behind the commandlines :)

and both commands of you make sense on hiw own way....

than are just the Progression left :)
Can you explain what you expect the progression to do? I had mentioned the last few lines are correct in my first reply.

 
That's on me.

Code:
<setattribute xpath="/lootcontainers/lootgroup[@name='beverages']/item[@name='drinkJarEmpty']" name="prob">1.5</setattribute>
 
Works fine :) tyvm for spent so much time just to help me.
did you have any solution for my Progression ^^ ?
I'm not an expert on the progression, but try these small tweaks...

1) you are adding an <attribute to the progression node. It probably should be under the <attributes> tag

Code:
<configs>
<append xpath="/progression/attributes">
        	<attribute name="attLuck"
               <!-- snip -->
      </append>

      <append xpath="/progression/skills" >
            <!-- all your skills -->
       </append>
      <append xpath="/progression/perks">
          <!-- all your perk name lines -->
      </append>
</configs>
 
At my Progression Attribute Luck:

<attribute name="attLuck" name_key="attLuckName" desc_key="attLuckDesc" icon="ui_game_symbol_skull_crusher">


<level_requirements level="1"><requirement name="PlayerLevel" target="self" operation="GTE" value="1" desc_key="reqGenericLevel01"/></level_requirements>



<level_requirements level="2"><requirement name="PlayerLevel" target="self" operation="GTE" value="5" desc_key="reqGenericLevel02"/></level_requirements>



<level_requirements level="3"><requirement name="PlayerLevel" target="self" operation="GTE" value="10" desc_key="reqGenericLevel03"/></level_requirements>



<level_requirements level="4"><requirement name="PlayerLevel" target="self" operation="GTE" value="15" desc_key="reqGenericLevel04"/></level_requirements>



<level_requirements level="5"><requirement name="PlayerLevel" target="self" operation="GTE" value="20" desc_key="reqGenericLevel05"/></level_requirements>



<level_requirements level="6"><requirement name="PlayerLevel" target="self" operation="GTE" value="30" desc_key="reqGenericLevel06"/></level_requirements>



<level_requirements level="7"><requirement name="PlayerLevel" target="self" operation="GTE" value="45" desc_key="reqGenericLevel07"/></level_requirements>



<level_requirements level="8"><requirement name="PlayerLevel" target="self" operation="GTE" value="60" desc_key="reqGenericLevel08"/></level_requirements>



<level_requirements level="9"><requirement name="PlayerLevel" target="self" operation="GTE" value="80" desc_key="reqGenericLevel09"/></level_requirements>



<level_requirements level="10"><requirement name="PlayerLevel" target="self" operation="GTE" value="100" desc_key="reqGenericLevel10"/></level_requirements>



<effect_group>



<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.35" level="1,9"/>



<passive_effect name="PlayerExpGain" operation="perc_add" value="1.5" level="10"/>


 


<passive_effect name="BlockDamage" operation="perc_add" value="0.025,0.225" level="1,9"/>



<passive_effect name="BlockDamage" operation="perc_add" value="0.25" level="10"/>


 


<effect_description level="1" desc_key="attLuckRank1Desc"/>



<effect_description level="2" desc_key="attLuckRank2Desc"/>



<effect_description level="3" desc_key="attLuckRank3Desc"/>



<effect_description level="4" desc_key="attLuckRank4Desc"/>



<effect_description level="5" desc_key="attLuckRank5Desc"/>


 


</effect_group>



</attribute>


as you see, the attribute self gives small benefits to EXP and BlockDmg. which i need to implement too anywise

 
NVM,. it works fine now :)

so how do i edit the localization file? cuz its a simple txt
We don't have the ability yet to change or add values to the localization.txt files from the mods folder.

 
I'm back again :D with a new question :)

can you explain me the issue here?

<set xpath="/blocks/block[@name=terrDesertGround]/drop[@name=resourceClayLump]/@count">3,5</set>

Looks like the code dosen't accept digits with a comma between, but i though count="3,5" means i get a amount between 3 and 5

 
Last edited by a moderator:
Back
Top