Jump to content
sphereii

XPath Modding Explanation Thread

Recommended Posts

A quick and easy solution to the issue is to use two xpath commands:

 

<remove xpath="//property" />

<append xpath="//property/@value>50</append>

 

The remove should fail silently if its not there, and remove if it its there. the append would put it back.

Like so?

Share this post


Link to post
Share on other sites

Probably something like this:

 

<remove xpath="/blocks/block[@name='woodFrameWedge']/property[@name='MaxDamage']" />
<append xpath="/blocks/block[@name='woodFrameWedge']">
     <property name="MaxDamage" value="75" >
</append>

 

If you aren't appending specifically to a value, but rather an entirely new line, it'll be the slightly longer format.

Share this post


Link to post
Share on other sites
Probably something like this:

 

<remove xpath="/blocks/block[@name='woodFrameWedge']/property[@name='MaxDamage']" />
<append xpath="/blocks/block[@name='woodFrameWedge']">
     <property name="MaxDamage" value="75" >
</append>

 

If you aren't appending specifically to a value, but rather an entirely new line, it'll be the slightly longer format.

Ah, yes, my mistake, you had explained that already. Thanks.

Share this post


Link to post
Share on other sites

Exellent intro.

 

 

Possible bug report:

 

You used append once with and once without comma. I assume only one method is correct.

 

<append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">,NoAmmo</append>

<append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">NoAmmo</append>

Share this post


Link to post
Share on other sites
Exellent intro.

 

 

Possible bug report:

 

You used append once with and once without comma. I assume only one method is correct.

 

<append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">,NoAmmo</append>

<append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">NoAmmo</append>

 

yes, the first one is correct. I'll update the post. It appends as a string, so it doesn't know any context on what it's changing.

Share this post


Link to post
Share on other sites

<items>
<item id="40" name="gunPistol">
	<!-- snip -->
	<property class="Action0">
		<!-- snip -->
		<property name="Magazine_items" value="9mmBullet" />
	</property>
</item>
</items>

 

 

Lets assume I want to add something OUTSIDE the <property> block for all guns with 9mm Bullets.

 

The following will surely not work because inbetween the append and the remove the xml is left with broken syntax with two closing </property>. And the remove surely wouldn't work this way anyway

 

<append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']>
 </property>
 <...my new stuff....>
</set>

<remove xpath="/items/item//property[2]">

 

Is there are way? Maybe a '..' syntax to go outside a block again?

Edited by meganoth (see edit history)

Share this post


Link to post
Share on other sites
Lets assume I want to add something OUTSIDE the <property> block for all guns with 9mm Bullets.

 

The following will surely not work because inbetween the append and the remove the xml is left with broken syntax with two closing </property>. And the remove surely wouldn't work this way anyway

 

<append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']>
 </property>
 <...my new stuff....>
</set>

<remove xpath="/items/item//property[2]">

 

Is there are way? Maybe a '..' syntax to go outside a block again?

 

You'd probably want to use <insertAfter>, rather than append.

 

<insertAfter xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']>
  <...my new stuff....>
</insertAfter>

Share this post


Link to post
Share on other sites

What's the actual full file look like for say items.xml using this system? Most examples don't include any overall structure where some include <configs> ... </configs> with changes inside. Are there tags that were left out?

Share this post


Link to post
Share on other sites
What's the actual full file look like for say items.xml using this system? Most examples don't include any overall structure where some include <configs> ... </configs> with changes inside. Are there tags that were left out?

 

Simplest Example:

 

Mods/Buggi/Config/items.xml:

 

<configs>
        <!-- this will insert new stuff under the <property name="Magazine_items" value="9mmBullet" />
        <insertAfter xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']>
                 <...my new stuff....>
         </insertAfter>

          <!-- this will change the value of the CreativeMode to false, rather than the default none -->
         <set xpath="/items/item[@name='clubMaster']/property[@name='CreativeMode']/@value">False</set>

</configs>

 

The <configs> tags aren't really used at all; they are just there to make a valid XML file, which needs a root node. This is just as valid:

 

<buggi>
        <insertAfter xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']>
                 <...my new stuff....>
         </insertAfter>
</buggi>

 

Does this help clear things up?

Share this post


Link to post
Share on other sites

Thank you for posting this. This should help a lot. tbh i'm terrible at modding and codes, but, I got annoyed with having to edit the xml after updates to get my glass jars back after cooking with them. *cant nobody do the dishes* :p so once we get it and i can figure this out, it is going to save me so much time and frustration. appreciate ya!

Share this post


Link to post
Share on other sites
Thank you for posting this. This should help a lot. tbh i'm terrible at modding and codes, but, I got annoyed with having to edit the xml after updates to get my glass jars back after cooking with them. *cant nobody do the dishes* :p so once we get it and i can figure this out, it is going to save me so much time and frustration. appreciate ya!

 

Looking forward to seeing your work :) Let us know if you have any issues with generating your xpath.

Share this post


Link to post
Share on other sites

I have no idea on what you said. I did manage to pick out some of it....like the words and, the, to, etc. I still think you did a wonderful job though as I imagine it is on par with your other posts. Glad you liked 7 Days enough to be involved like this. We all benefit from that. Thank you.

 

 

 

...oh btw, can you loan me $10 til Friday...

Share this post


Link to post
Share on other sites
I have no idea on what you said. I did manage to pick out some of it....like the words and, the, to, etc. I still think you did a wonderful job though as I imagine it is on par with your other posts. Glad you liked 7 Days enough to be involved like this. We all benefit from that. Thank you.

 

 

 

...oh btw, can you loan me $10 til Friday...

 

<append xpath="/bankAccounts/Account[@name='Gamida']/@balance">+$10</append>

  • Like 1

Share this post


Link to post
Share on other sites

In which folder do you place the mod folder and do you need to specify the mod somewhere for the game to use it? I tried to do a search for this information but I couldn't find it. I would like to try this instead of modifying the source files even though I wrote a program to do the modifying for me because this seems to be a much more elegant solution and safer.

Share this post


Link to post
Share on other sites
In which folder do you place the mod folder and do you need to specify the mod somewhere for the game to use it? I tried to do a search for this information but I couldn't find it. I would like to try this instead of modifying the source files even though I wrote a program to do the modifying for me because this seems to be a much more elegant solution and safer.

 

At the top level of your game folder (C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die), make a Mods folder. Then, under that, make a folder for each of the mods you want to make.

 

C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die\Mods\BloodMoonTrickle
C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die\Mods\Zicky\

 

Under your Zicky folder, you should have this:

 

Config/entityclasses.xml  ( if you want to make a change to the entityclasses.xml file )
ModInfo.xml

 

The game will look in the Mods folder for mods automatically; As long as it has a ModInfo.xml, it'll try to load it.

Share this post


Link to post
Share on other sites

Do you know in what order the mods are applied? I'm assuming that it is most likely going to be trying to parse them alphabetically.

 

May do some testing later today to see if that seems to be the case

Share this post


Link to post
Share on other sites
Do you know in what order the mods are applied? I'm assuming that it is most likely going to be trying to parse them alphabetically.

 

May do some testing later today to see if that seems to be the case

 

It's alphabetical :)

 

Changes start from the top and end with the last mod in the folder.

Share this post


Link to post
Share on other sites

(Have not tested this yet - will attempt to do so when I get home tonight)

 

How about adding/changing things within the text files such as the locilization.txt?

Share this post


Link to post
Share on other sites
(Have not tested this yet - will attempt to do so when I get home tonight)

 

How about adding/changing things within the text files such as the locilization.txt?

 

Not at this point. Maybe layer in A17 or possibly in A18.

Share this post


Link to post
Share on other sites

Wow this is what I have wanted for months. Thank you Sphereii for explaining it.

Jittering with excitment

Share this post


Link to post
Share on other sites

One Question beside this: Has anything changed regarding sprites transfer from server to client? This would be awesome for dedicated servers having custom UI's without the need that everybody has installed the mod them self.

Share this post


Link to post
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...