• 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:
right. is it because they are 2 different item rather than 2 of the item in 1 group?
It's just the condition you set up. You want to change any item with this name, or this other name.

Other conditions would be I want to change an item with a property called extends and a value called meleeShiv, for example.

 
Is it possible to add something to localization.txt? maybe like

Code:
<append xpath="">
NEWITEMDesc,items,Tool,KgNone,random description.,,,,,
</append>
Ive another doubt although it's not a xpath one, but which property I add to give my new item a nickname? property DescriptionKey is the description tab text, which works when I manually edit localization. But I cant figure it out how to change the name, it shows the raw name in-game.

Thanks

 
so its also impossible to add a name for a new item different than what you actually name it in items.xml?
The issue is that Xpath won't deal with the localization file because it is a text file. You would have to manually give it to your clients.

 
The issue is that Xpath won't deal with the localization file because it is a text file. You would have to manually give it to your clients.
I have a potential gap solution that will help us, while we wait for vanilla support.

 
I want to change the value in this and having issues I am just trying to change only the reset_interval value

Code:
<trader_info id="1" min_inventory="40" max_inventory="120" min_items_swapped="20" 
	max_items_swapped="20" reset_interval="1" open_time="6:05" close_time="21:50">
I know I am missing something or it's not correct.

Code:
<configs>
<set xpath="traders/trader_item_groups/trader_info[@id='1']/@reset_interval">1</set>
</configs>
------- Figured it out ---------

Code:
<set xpath="traders/trader_info[@id='1']/@reset_interval">1</set>
 
Last edited by a moderator:
Hey everyone :)

i used my new attribute to increased EXP Gain Rate

Code:
<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"/>
now i want, thats the Bonus XP only applied on Killing Enemys would it be enough to add just behind the level="XY"

Code:
 tag="zombie,walker,feral,radiated,hostile,animal"
and would looks like:

Code:
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.35" level="1,9" tag="zombie,walker,feral,radiated,hostile,animal"/>
		<passive_effect name="PlayerExpGain" operation="perc_add" value="1.5" level="10"tag="zombie,walker,feral,radiated,hostile,animal"/>
works this xD ?

- - - Updated - - -

Hey everyone :)

i used my new attribute to increased EXP Gain Rate

Code:
<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"/>
now i want, thats the Bonus XP only applied on Killing Enemys would it be enough to add just behind the level="XY"

Code:
 tag="zombie,walker,feral,radiated,hostile,animal"
and would looks like:

Code:
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.35" level="1,9" tag="zombie,walker,feral,radiated,hostile,animal"/>
<passive_effect name="PlayerExpGain" operation="perc_add" value="1.5" level="10"tag="zombie,walker,feral,radiated,hostile,animal"/>
works this xD ?

 
So another question with how do I skip to white river citizen 1 after crafting bedrolls? I guess I really don't understand how it should work :upset:

Code:
<set xpath="/quests/quest[@id='quest_BasicSurvival1']/reward[@type='Quest']/@value">quest_whiteRiverCitizen1</set>
I tried using remove earlier and it just doesn't load the mod.

Code:
<remove xpath="/quests/quest[@id='quest_BasicSurvival1']/reward[@type='Quest']/@id="quest_whiteRiverCitizen1" />
 
So another question with how do I skip to white river citizen 1 after crafting bedrolls? I guess I really don't understand how it should work :upset:

Code:
<set xpath="/quests/quest[@id='quest_BasicSurvival1']/reward[@type='Quest']/@value">quest_whiteRiverCitizen1</set>
I tried using remove earlier and it just doesn't load the mod.

Code:
<remove xpath="/quests/quest[@id='quest_BasicSurvival1']/reward[@type='Quest']/@id="quest_whiteRiverCitizen1" />
Take a look at Red Eagle LXIX's work: https://7daystodie.com/forums/showthread.php?94219-Red-Eagle-LXIX-s-A17-Modlet-Collection-(UI-Blocks-Quests)

- - - Updated - - -

Hey everyone :)
i used my new attribute to increased EXP Gain Rate

Code:
<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"/>
now i want, thats the Bonus XP only applied on Killing Enemys would it be enough to add just behind the level="XY"

Code:
 tag="zombie,walker,feral,radiated,hostile,animal"
and would looks like:

Code:
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.35" level="1,9" tag="zombie,walker,feral,radiated,hostile,animal"/>
		<passive_effect name="PlayerExpGain" operation="perc_add" value="1.5" level="10"tag="zombie,walker,feral,radiated,hostile,animal"/>
works this xD ?

- - - Updated - - -

Hey everyone :)

i used my new attribute to increased EXP Gain Rate

Code:
<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"/>
now i want, thats the Bonus XP only applied on Killing Enemys would it be enough to add just behind the level="XY"

Code:
 tag="zombie,walker,feral,radiated,hostile,animal"
and would looks like:

Code:
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.35" level="1,9" tag="zombie,walker,feral,radiated,hostile,animal"/>
<passive_effect name="PlayerExpGain" operation="perc_add" value="1.5" level="10"tag="zombie,walker,feral,radiated,hostile,animal"/>
works this xD ?
I'm sorry, I'm not clear on what you are looking for.

Is this the new code you want to add?

Code:
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.35" level="1,9" tag="zombie,walker,feral,radiated,hostile,animal"/>
<passive_effect name="PlayerExpGain" operation="perc_add" value="1.5" level="10"tag="zombie,walker,feral,radiated,hostile,animal"/>
If so, which file and location did you want to add it?

 
Happy Xmas Sphereii.

ok lets focus on the line:

Code:
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.5" level="1,10"
This is the Passive effect of my "Attribute".

The Issue here is:

PlayerExpGain applied on every EXP Source, like Chopping trees, Digging holes in dirt and Stone, Selling items and using console command for exp...

At the Point where i sold large amount of Stuff to traders, ridiculous amount of EXP appears and even if the worth of exp grows over 65k its goes into an infinite amount of EXP which skipped the char to th LV Cap.

What i want to do is. Set the Passive_effect to only trigger when the player kills Animals and Zombies. No more Exp Bonus for Console commands, Chopping trees or other works, or for Trading - and so on... only Exp bonus for Killing Animals and Zombies.

I Also tryied things like: -spoiler- DONT WORKS

Code:
<effect_group>
<requirement name="onSelfAttackedOther" target="other" target_tags="zombie,animal"/>
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.5" level="1,10" target="self"/>
</effect_group>
would be grateful for any solution.

 
Last edited by a moderator:
Happy Xmas Sphereii.
ok lets focus on the line:

Code:
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.5" level="1,10"
This is the Passive effect of my "Attribute".

The Issue here is:

PlayerExpGain applied on every EXP Source, like Chopping trees, Digging holes in dirt and Stone, Selling items and using console command for exp...

At the Point where i sold large amount of Stuff to traders, ridiculous amount of EXP appears and even if the worth of exp grows over 65k its goes into an infinite amount of EXP which skipped the char to th LV Cap.

What i want to do is. Set the Passive_effect to only trigger when the player kills Animals and Zombies. No more Exp Bonus for Console commands, Chopping trees or other works, or for Trading - and so on... only Exp bonus for Killing Animals and Zombies.

I Also tryied things like: -spoiler- DONT WORKS

Code:
<effect_group>
<requirement name="onSelfAttackedOther" target="other" target_tags="zombie,animal"/>
<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.5" level="1,10" target="self"/>
</effect_group>
would be grateful for any solution.
I think we can come up with a solution. When you say passive effect on your attribute, which file is your attribute at, what what's it called?

 
Code:
<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="reqPlayerAndPoint1"/></level_requirements>
	<level_requirements level="2"><requirement name="PlayerLevel" target="self" operation="GTE" value="3" desc_key="reqPlayerAndPoint2"/></level_requirements>
	<level_requirements level="3"><requirement name="PlayerLevel" target="self" operation="GTE" value="5" desc_key="reqPlayerAndPoint3"/></level_requirements>
	<level_requirements level="4"><requirement name="PlayerLevel" target="self" operation="GTE" value="10" desc_key="reqPlayerAndPoint4"/></level_requirements>
	<level_requirements level="5"><requirement name="PlayerLevel" target="self" operation="GTE" value="15" desc_key="reqPlayerAndPoint5"/></level_requirements>
	<level_requirements level="6"><requirement name="PlayerLevel" target="self" operation="GTE" value="20" desc_key="reqPlayerAndPoint6"/></level_requirements>
	<level_requirements level="7"><requirement name="PlayerLevel" target="self" operation="GTE" value="25" desc_key="reqPlayerAndPoint7"/></level_requirements>
	<level_requirements level="8"><requirement name="PlayerLevel" target="self" operation="GTE" value="30" desc_key="reqPlayerAndPoint8"/></level_requirements>
	<level_requirements level="9"><requirement name="PlayerLevel" target="self" operation="GTE" value="40" desc_key="reqPlayerAndPoint9"/></level_requirements>
	<level_requirements level="10"><requirement name="PlayerLevel" target="self" operation="GTE" value="50" desc_key="reqPlayerAndPoint10"/></level_requirements>
		<effect_group>
		<passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.5" level="1,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_description level="6" desc_key="attLuckRank6Desc"/>
		<effect_description level="7" desc_key="attLuckRank7Desc"/>
		<effect_description level="8" desc_key="attLuckRank8Desc"/>
		<effect_description level="9" desc_key="attLuckRank9Desc"/>
		<effect_description level="10" desc_key="attLuckRank10Desc"/>

		</effect_group>
</attribute>
Its a part of my "Progression.xml"

 
Try something like this. It'll add your new passive_effect to the effect_group of the attribute attLuck

Code:
<append xpath="/progression/attributes/attribute[@name='attLuck']/effect_group" >
         <passive_effect name="PlayerExpGain" operation="perc_add" value="0.15,1.5" level="1,10"
</append>
 
Hi there,

I want to change the Run or Sprint speed global setting for zombies. Is this one global value in one config file that needs changing or do I have to change the values for every zombie in entitieclasses.xml?

 
Last edited by a moderator:
The passive it selfs works fine, and don't need to be add to luck, cuz its already a part of the attribute Luck....

but again :)

The passive works with the effect of giving Percentage Bonus XP. My Main Issue there is, thats these Percentage Bonus XP apllied on each kind of EXP i gained. I would reduced this to the Source of Killing Enemys(Zombies,Animals). I dont want gain Percentage more XP by Working, Upgrading or Trading. I need to reduce the PlayerGainExp effect only on Killing Zombies, Animals....

 
Ok here's a doosy for you all..

Changing a value that has two seperate values, such as

<Temperature min="-60" max="-30" prob="1"/>

to change both the min and the max .. I cannot for the life of me figure the correct syntax for the <set>.. I've tried using <append>, nothing happened. Tried the contains, still no go.

Any ideas?

 
Ok here's a doosy for you all..
Changing a value that has two seperate values, such as

<Temperature min="-60" max="-30" prob="1"/>

to change both the min and the max .. I cannot for the life of me figure the correct syntax for the <set>.. I've tried using <append>, nothing happened. Tried the contains, still no go.

Any ideas?
you are overthinking it :)

Code:
 <!-- Set all global temperatures to be the same range-->
 <set xpath="/worldgeneration/biomes/biome/weather/Temperature/@min">-60</set>
 <set xpath="/worldgeneration/biomes/biome/weather/Temperature/@max">-30</set>
 
Back
Top