Jump to content

Xpathing help Alpha 21


Recommended Posts

Hello. I am dipping my toes into modding 7 days to die. I am new to using xpathing and I wanted to make sure I had some of my expressions correct.

 <set xpath="/progression/perk[name='perkLockPicking']"/effect_group/passive_effect[name='LockPickTime']/@value">.25,.75</set>

is an example of one of them. that should I believe change the lockpick time.

<configs>
	<append xpath="/items">
		<item name="Googly Eye Glasses">
			<property name="Extends" value="apparelShades"/>
			</effect_group>
		</item>
	</append>
</configs>

would add that to the items root path correct?

Link to comment
Share on other sites

First one needs to be:

 

xpath="/progression/perks/perk[@name='perkLockPicking']/effect_group/passive_effect[@name='LockPickTime']/@value">

 

  • The entire path has to be between two ".  You had an extra one after perkLockPicking]
  • The code is structured in layers, you missed a sublayer between progression and perk (perks)
    • Recommend getting a good xml editing program that shows the layers of code, I use Notepad++ myself
    • One way to avoid these types of error is just to do this
xpath="//perk[@name='perkLockPicking']/effect_group/passive_effect[@name='LockPickTime']/@value">

 

  • You need the @ symbol with name.  That tells the game to find passive_effect with Name = LockPickTime and the specific perk

Second one has several issues, but it would add it to the items.xml file at the bottom:

  • In the item name, do not use spaces.  It needs to be continuous to avoid any issues.
    • If you want to have spaces in the name when you view it in game, you need to add it to the localization file which allows spaces
  • You have </effect_group> closed out but have no starting effect group in the code.
Edited by BFT2020 (see edit history)
Link to comment
Share on other sites

So for the lockpick example.. I came up with  this. I have a 
 

\

\Config

\Config\progression.xml
\ModInfo.xml

the progression XML is 

<configs>
	<!-- Changes lockpicking to be actually useful and make sense to spend points on. -->
	<set xpath="//perk[@name='perkLockPicking']/effect_group/passive_effect[@name='LockPickTime']/@value">.25,.75</set>
	<set xpath="//progression/perk[name='LockPickBreakChance']/effect_group/passive_effect[name='LockPickTime']/@value">.33,100</set>
</configs>

 

and the modinfo is

<?xml version="1.0" encoding="UTF-8" ?>

<xml>
<ModInfo>
    <Name value="Drats Skills" /> <!-- (Required) Internal name, like an ID, of the mod. Should be globally unique, like an author prefix + name. Only allowed chars: Numbers, latin letters, underscores, dash -->
    <DisplayName value="Drats Skills" /> <!-- (Required) Name used for display purposes, like shown in the mods UI at some point. Could be the same as you would later on use on workshop or wherever mods get distributed -->
    <Version value="0.1" /> <!-- (Required) SemVer version of the mod. Has to be in the format major.minor[.build[.revision]] (i.e. build and revision can be left out, recommend using them though as typically done with Semantic Versioning -->
    <Description value="Changes some perks" /> <!-- (Optional) More text to show on UIs -->
    <Author value="Drats666" /> <!-- (Optional) Name(s) of the author(s) -->
   	<Website value="N/A"/>
</ModInfo>
</xml>

However when going into a test world that I made after putting it into my mods folder. it doesn't seem to have worked.  did I miss something?

Link to comment
Share on other sites

2 hours ago, drats said:
<configs>
	<!-- Changes lockpicking to be actually useful and make sense to spend points on. -->
	<set xpath="//perk[@name='perkLockPicking']/effect_group/passive_effect[@name='LockPickTime']/@value">.25,.75</set>
	<set xpath="//progression/perk[name='LockPickBreakChance']/effect_group/passive_effect[name='LockPickTime']/@value">.33,100</set>
</configs>

The "name" of the second xpath is missing an @!
And there is no perk with the name "LockPickBreakChance".
Maybe that's why you missed it!
Unless you're trying to modify a skill created by another mod!

 

If I'm right, maybe that's what you want to do:

 

<configs>
      <!-- Changes lockpicking to be actually useful and make sense to spend points on. -->
      <set xpath="//perk[@name='perkLockPicking']//passive_effect[@name='LockPickTime']/@value">.25,.75</set>
      <set xpath="//perk[@name='perkLockPicking']//passive_effect[@name='LockPickBreakChance']/@value">.33,100</set>
</configs>

I've reduced the size of the xpath and made it more readable!

Using "//", you can search for all passive effects following the hierarchy, without having to mention effect_group or other nodes!
In this case, I've already mentioned which perk I want to select and then skipped all the nodes directly to any passive_effect!


 

Elements don't need @ but attributes do!
Element is what is inside the beginning of <>
Example, <effect_group>, so "effect_group" is an element!
What comes after "effect_group" is an attribute
Example, <effect_group name="attributeValue1">
In this case, the attribute is "name" and its value is "attributeValue1".
So you can select a specific "effect_group/@name" by searching for the value, or you can search for all "effect_group/@name" and edit them all at the same time!

 

Searching for a specific one (use [] after the element to select an attribute from it as a requirement):

//perk/effect_group[@name='attributeValue1']


Searching for all effect_groups that have @name!

//perk/effect_group[@name]

And if you want to select the attribute instead of the element, you have to put the @attribute after the element in the xpath
So this:

//perk/effect_group[@name='attributeValue1']


Will become this:

//perk/effect_group[@name='attributeValue1']/@name
<perks>
    <perk>
        <effect_group name="attributeValue1"></effect_group>
        <effect_group name="attributeValue2"></effect_group>
    </perk>
</perks>


Use the XML above to test the XPATHS I mentioned, you can use "https://codebeautify.org/Xpath-Tester" to test!

And you can also look at this documentation on the WIKI, it will help you a lot!
https://7daystodie.fandom.com/wiki/XPath_Explained

There are several ways to select a single node!
Test enough to select as simply as possible!

Edited by Luduaver (see edit history)
Link to comment
Share on other sites

Some things that will help you:

 

  • Every game session generates a logfile, use it to see if there are any warnings or errors when you load up the game.
  • I am not sure if mod file names can have spaces.  At the very least, use an underscore between Drats and Skills.
  • In the roaming file location, you can find the save worlds / save game data.  In the game save file folder, it will have a config folder in it that represents what the game did when it loaded up your mod.  If you search in progression.xml for Drats, it will find every instance where this mod made changes to the vanilla xml code
  • Look closely at your second set command, you are not even close to the proper structure - layers, perk name, the values you have chosen to replace vanilla values
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...