Jump to content

XPath Modding Explanation Thread


Recommended Posts

I not speak english. Sorry my english.

Not work:

<removeattribute xpath="/Sounds/SoundDataNode[@name=Auger_Fire_Start]/Noise/heat_map_strength" />

Work:

<removeattribute xpath="/Sounds/SoundDataNode[@name=Auger_Fire_Start]/Noise/@heat_map_strength" />

 

A18

 

Thanks for the description. Greatly help.

Edited by MxSam (see edit history)
Link to post
Share on other sites

hello, I'm looking for some help if u dont mind :c

 

Because I changed max stacks of items I also need to change the bundles to something more appropriate. So I did, but their names specify how many units they used to contain.

 

I need to change the name of the bundle items.

 

1 - preferred method through a property, couldn't find one working so far.

 

2 - localization file, I dislike that they would need to download it but whatever, thing is I put the localization file with the exact same name and structure in the indicated folder, loaded the game, the changes aren't reflected there yet no error is shown.

 

would you know a property to change its name or take a look at my localization file? its inside the config folder of the mod.

 

thanks!

 

[ATTACH]30417[/ATTACH]

Localization.txt

Edited by danielspoa (see edit history)
Link to post
Share on other sites
Yeh, he's adding it to Sam Neils world (see prefab section). If Sam packages it correctly (they're both learning how I think?), it'll be a non issue for him.

 

Yeah, I think sam incorporated into his v14 so my installation instructions probably no longer needed...😂

Link to post
Share on other sites

Hi guys. I feel really, really dumb. I've tried and tried to grasp XPath and been through the tutorials and looked at other mods and I just cannot get the syntax of it right. Sometimes it works for me, but mostly it doesn't seem to.

 

Can someone help me understand how to alter the birdnest block as an example and maybe I can finally get a firm understanding of how some of this is supposed to be properly done? I picked this block because I do want to change it and also I think it's a good example of covering several different cases such as altering, removing and appending lines.

 

Here's what I could really use help with:

 

1) Does the name of the XML file in a modlet matter? For example Can I use birdnest.xml to implement changes (provided I use proper syntax and nesting) or does it need to be blocks.xml ?

 

2) Does nesting in the XML file need to contain <config> or <configs>? Is there a necessary syntax for that (it doesn't seem so judging from other modlets I looked at trying to understand). Can I just use <JRavens> or <blahblahblah> so long as it has the requisite closing piece </JRavens>, </blahblahblah> etc.

 

3) Let's say I want to change a blocks material. In this example changing the birdnest from Wood to Grass (because well I think it's a little silly that birdnests have 100 health, clunk when you walk over them and explode into wood chips when destroyed). I tried this with no success:

 

<set xpath="/blocks/block[@name='cntBirdnest']/property[@name='Material']/@value">Mtallgrass</set>

 

4) Since I don't want bird nests to be harvested (just destroyed) I want to alter the harvest and destroy lines

(i.e. I want to player to get a some fibers and maybe some additional feathers when a nest is destroyed)

 

So I want to remove these lines:

	<drop event="Harvest" name="resourceCloth" count="1" prob="0.3" tag="allHarvest"/>
<drop event="Harvest" name="resourceFeather" count="3" prob="0.35" tag="allHarvest"/>
<drop event="Harvest" name="resourceFeather" count="2" prob="0.6" tag="allHarvest"/>

 

What's the proper syntax to remove those drop events?

 

5) Then say I want to alter this line to drop say half as many max fibers:

	<drop event="Destroy" name="resourceYuccaFibers" count="2,8"/>

 

So would this be a correct way to change that line??

<set xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceYuccaFibers']/@count">2,4</set>

 

6) Finally lets say I want to append (add) in some lines to give a chance to drop some feathers (bird feathers often get stuck in nests and are even used when building them... actually lets go ahead and add back in a tiny chance for cloth or even paper to have been used as material for the nest...).

 

Would this code be proper?

<append xpath="/blocks/block[@name='cntBirdnest']" > 
<drop event="Destroy" name="resourceFeather" count="0,6" prob="0.8"/>
<drop event="Destroy" name="resourceCloth" count="0,1" prob="0.01"/>
<drop event="Destroy" name="resourcePaper" count="0,1" prob="0.01"/>
</append>

 

 

Thanks for any help and / or pointers. I am really struggling with this for some reason. I've never been good with code / regex style strings and such... my brain just doesn't work that way. I much prefer plain text, but I understand the need for xpath and so I would like to understand how to compose it correctly so I cna make my own modlets / mods. Thank you :)

Link to post
Share on other sites
Hi guys. I feel really, really dumb. I've tried and tried to grasp XPath and been through the tutorials and looked at other mods and I just cannot get the syntax of it right. Sometimes it works for me, but mostly it doesn't seem to.

 

Can someone help me understand how to alter the birdnest block as an example and maybe I can finally get a firm understanding of how some of this is supposed to be properly done? I picked this block because I do want to change it and also I think it's a good example of covering several different cases such as altering, removing and appending lines.

 

Here's what I could really use help with:

 

1) Does the name of the XML file in a modlet matter? For example Can I use birdnest.xml to implement changes (provided I use proper syntax and nesting) or does it need to be blocks.xml ?

The files in the Mods/MyMod/Config folder must match the XML it's patching. You wouldn't be able to do birdnest.xml; you'd have to do blocks.xml, if the changes were in the blocks file. If you also need a recipe, you'd have to do a recipes.xml as well.

 

2) Does nesting in the XML file need to contain <config> or <configs>? Is there a necessary syntax for that (it doesn't seem so judging from other modlets I looked at trying to understand). Can I just use <JRavens> or <blahblahblah> so long as it has the requisite closing piece </JRavens>, </blahblahblah> etc.

 

The top node doesn't matter what its called, as long as you open and close it. The top node is required because its part of the XML standard, but the game itself doesn't use the value in it.

 

 

3) Let's say I want to change a blocks material. In this example changing the birdnest from Wood to Grass (because well I think it's a little silly that birdnests have 100 health, clunk when you walk over them and explode into wood chips when destroyed). I tried this with no success:

 

<set xpath="/blocks/block[@name='cntBirdnest']/property[@name='Material']/@value">Mtallgrass</set>

In order for the game to pick this up, it'd have to be Config/blocks.xml

 

 

4) Since I don't want bird nests to be harvested (just destroyed) I want to alter the harvest and destroy lines

(i.e. I want to player to get a some fibers and maybe some additional feathers when a nest is destroyed)

 

So I want to remove these lines:

	<drop event="Harvest" name="resourceCloth" count="1" prob="0.3" tag="allHarvest"/>
<drop event="Harvest" name="resourceFeather" count="3" prob="0.35" tag="allHarvest"/>
<drop event="Harvest" name="resourceFeather" count="2" prob="0.6" tag="allHarvest"/>

 

What's the proper syntax to remove those drop events?

 

You would use the remove node.

<remove xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceCloth']" />
<remove xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceFeather']" />
<remove xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceFeather']" />

 

This may also work, however I don't think it worked in A17:

<remove xpath="/blocks/block[@name='cntBirdnest']/drop" />

 

5) Then say I want to alter this line to drop say half as many max fibers:

<drop event="Destroy" name="resourceYuccaFibers" count="2,8"/>

 

So would this be a correct way to change that line??

<set xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceYuccaFibers']/@count">2,4</set>

 

Yes, that line looks okay. Again, the changes would have to be done in a file calld blocks.xml

 

 

6) Finally lets say I want to append (add) in some lines to give a chance to drop some feathers (bird feathers often get stuck in nests and are even used when building them... actually lets go ahead and add back in a tiny chance for cloth or even paper to have been used as material for the nest...).

 

Would this code be proper?

<append xpath="/blocks/block[@name='cntBirdnest']" > 
<drop event="Destroy" name="resourceFeather" count="0,6" prob="0.8"/>
<drop event="Destroy" name="resourceCloth" count="0,1" prob="0.01"/>
<drop event="Destroy" name="resourcePaper" count="0,1" prob="0.01"/>
</append>

Yes, that'd be the correct xpath. I cannot confirm if the lines will do what you want them to do, since I don't have the files in front of me though.

 

Thanks for any help and / or pointers. I am really struggling with this for some reason. I've never been good with code / regex style strings and such... my brain just doesn't work that way. I much prefer plain text, but I understand the need for xpath and so I would like to understand how to compose it correctly so I cna make my own modlets / mods. Thank you :)

 

I hope this has helped a bit. Good luck, and ask more questions if you need help.

Link to post
Share on other sites
I hope this has helped a bit. Good luck, and ask more questions if you need help.

 

It did! Thank you very much sphereii.

 

I think I see now that a lot of my experiments were hit and miss because I wasn't always naming the files properly (bonehead assumption on my part).

 

I appreciate the help :)

Link to post
Share on other sites

Localization Support ( A18 and Beyond )

 

As of A18, Localization support from the Mods folder is available in vanilla.

 

In the Config folder, create a Localization.txt and a Localization - Quest.txt. This file must match case and spelling of the vanilla entries.

 

The localization files files have a heading, like the vanilla version, as a comma delimited line. For mod localization support, you only need to specify the heading that you are adding. For example, if your mod only contains localization for English, you do not need to specify the other language in the heading line.

 

If your new localization key matches a vanilla value, or a value from a previously loaded mod, then that value will be updated, with the last mod loaded having the final effect.

 

The format of the file is this:

 

HEADER

ENTRY

 

Example:

 

Key,Source,Context,Changes,English
myKey,UI,Item stat,New,This is my English Key

 

Note: If you are only including non-English translation, such as French, and leave the English blank or out, then a user loading the Spanish version will get the localization key. This is because English is the fall back translation. If you specify an English, then the spanish player will see the English localization.

 

Actually don't need to put all heading columns. Key and "Language" are enough to work.

 

Example:

 

English

Key,English
airConditioner,Air Conditioner

Spanish

Key,Spanish
airConditioner,Aire acondicionado

 

It works perfectlly with my Portuguese localization.

Link to post
Share on other sites
Actually don't need to put all heading columns. Key and "Language" are enough to work.

 

Example:

 

English

Key,English
airConditioner,Air Conditioner

Spanish

Key,Spanish
airConditioner,Aire acondicionado

 

It works perfectlly with my Portuguese localization.

 

Thank you for the update. That is replacing the existing vanilla localization. I wonder what would happen if you just included Key and language on a completely new item?

 

If someone loads your mod, and you only specify Portugesse or Spanish, and they do not have that set, they'll get the raw block or item name from the blocks.xml and items.xml. English is the fall back language to display, if an alternative language isn't specified.

Link to post
Share on other sites
Thank you for the update. That is replacing the existing vanilla localization. I wonder what would happen if you just included Key and language on a completely new item?

 

If someone loads your mod, and you only specify Portugesse or Spanish, and they do not have that set, they'll get the raw block or item name from the blocks.xml and items.xml. English is the fall back language to display, if an alternative language isn't specified.

 

It works to new items/blocks too.

 

Example of my vehicle respawning modlet with spanish language:

 

A18.1_2019-11-14_12-07-33.thumb.jpg.33e93f4273a40396b2c8a583a2a9264c.jpg

Key,Spanish
RespawnCarro,SAMUELPV's Car Respawning

Link to post
Share on other sites

Having some weird problems , trying to alter the icons on some of the vanilla items, for example scrapiron, using this line in a modlet items.xml

 

<append xpath="/items/item[@name=resourceScrapIron]/property[@name=HoldType]">

<property name="CustomIcon" value="iron"/>

</append>

 

but ending up with this looks in the items.xml under configdumps,

 

<item name="resourceScrapIron">

<property name="HoldType" value="45">

<property name="CustomIcon" value="iron"><!--Element appended by: "Holo's fixes"--></property>

</property>

 

what am i doing wrong? tried with append and insertafter but always ending up with the </property> that's not supposed to be there and making the lines unread by the server.

Link to post
Share on other sites
Having some weird problems , trying to alter the icons on some of the vanilla items, for example scrapiron, using this line in a modlet items.xml

 

<append xpath="/items/item[@name=resourceScrapIron]/property[@name=HoldType]">

<property name="CustomIcon" value="iron"/>

</append>

 

but ending up with this looks in the items.xml under configdumps,

 

<item name="resourceScrapIron">

<property name="HoldType" value="45">

<property name="CustomIcon" value="iron"><!--Element appended by: "Holo's fixes"--></property>

</property>

 

what am i doing wrong? tried with append and insertafter but always ending up with the </property> that's not supposed to be there and making the lines unread by the server.

 

Your append is too deep. You are telling it to append the CustomIcon lin to HoldType, so it looks like this:

 

<property name="HoldType" value="45" >
  <property name="CustomIcon" value="iron" />
</property>

You want this:

 

 

<append xpath="/items/item[@name='resourceScrapIron']">
<property name="CustomIcon" value="iron"/>
</append>

Link to post
Share on other sites
  • 2 weeks later...

Agh. I'll never get the hang of xpath it seems :/ I'm trying to remove items from the progression, so we -must- find the schematic,

trying to remove the whole line with

<remove xpath="/progression/perks/perk[@name=perkYeahScience]/effect_group[@tags=chemistryStation]" />

 

but the game won't allow that and I'm not sure how to remove things from progression and can't find any examples from other mods :(

Edited by -Holo-
forgot /progresson at the start of the line (see edit history)
Link to post
Share on other sites
Agh. I'll never get the hang of xpath it seems :/ I'm trying to remove items from the progression, so we -must- find the schematic,

trying to remove the whole line with

<remove xpath="/progression/perks/perk[@name=perkYeahScience]/effect_group[@tags=chemistryStation]" />

 

but the game won't allow that and I'm not sure how to remove things from progression and can't find any examples from other mods :(

 

You are close. The chemistryline is part of the passive_effect line, not the effectgroup itself. Once you target the passive_effect line, you can add the name attribute as an additional condition, or continue just to target the @tags='chemistryStation'.

<remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group/passive_effect[@name='RecipeTagUnlocked' and @tags='chemistryStation']" />

<remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group/passive_effect[@tags='chemistryStation']" />

Link to post
Share on other sites

Hello,

 

I'm having trouble with a "simple-ish" modlet I'm trying to make. I'm basically trying to change the % value of all zombies in game from 1 to .5 or 0.1 or whatever (aka, so they have less life). I want to do it through the % values so the game balance stays intact (somewhat).

 

The game loads the mod properly at the start of the game, displays the version, but it doesn't do anything. The zombies have the same health value as they had before.

 

This is my modlet code for the entityclasses.xml:

 

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

<entityclasses>

<set xpath="/entity_classes/entity_class[starts-with(@name,'zombie')]/effect_group[@name='Base Effects']/passive_effect[@name='HealthMax'][@operation='perc_set'][@value='1']/@value">.1</set>

</entityclasses>

 

What did I mess up?

 

p.s. sphereii, bless your soul for helping us

Link to post
Share on other sites
Hello,

 

I'm having trouble with a "simple-ish" modlet I'm trying to make. I'm basically trying to change the % value of all zombies in game from 1 to .5 or 0.1 or whatever (aka, so they have less life). I want to do it through the % values so the game balance stays intact (somewhat).

 

The game loads the mod properly at the start of the game, displays the version, but it doesn't do anything. The zombies have the same health value as they had before.

 

This is my modlet code for the entityclasses.xml:

 

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

<entityclasses>

<set xpath="/entity_classes/entity_class[starts-with(@name,'zombie')]/effect_group[@name='Base Effects']/passive_effect[@name='HealthMax'][@operation='perc_set'][@value='1']/@value">.1</set>

</entityclasses>

 

What did I mess up?

 

p.s. sphereii, bless your soul for helping us

 

It seems to be a valid xpath. Have you checked your exported configs, under your SaveGame folder to see if it applied the changes you expect? It could be that what you are changing isn't the final determination on what the health of a zombie has.

Link to post
Share on other sites
It seems to be a valid xpath. Have you checked your exported configs, under your SaveGame folder to see if it applied the changes you expect? It could be that what you are changing isn't the final determination on what the health of a zombie has.

 

I presume it's the thing under %appdata% so I went there, specifically under "C:\Users\PCuser\AppData\Roaming\7DaysToDie\Saves\Navezgane\myworld\ConfigsDump\entityclasses.xml"

 

And yes, as you said, it didn't apply the changes there.

Another thing that I forgot to mention is that I tried changing these values manually and when I changed them manually with notepad++ (all 84 lines that matched that line and the value "1") it applied the HP change as intended. Since that worked I went and tried to make a modlet that would do the same but unfortunately it didn't work :/

 

The only other mod I'm using is the SMX hud overhaul but I doubt that would be causing any conflicts.

Wat do? Am I perhaps missing something with my mod structure? I attached an image below showing my whole folder structure for the mod.

 

ModStructure.jpg.60f26b9866db764b15c009b416d3a39a.jpg

Link to post
Share on other sites
You are close. The chemistryline is part of the passive_effect line, not the effectgroup itself. Once you target the passive_effect line, you can add the name attribute as an additional condition, or continue just to target the @tags='chemistryStation'.

<remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group/passive_effect[@name='RecipeTagUnlocked' and @tags='chemistryStation']" />

<remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group/passive_effect[@tags='chemistryStation']" />

 

Ahh Thanks! I was not aware one could have longer then a single 'item' here "effect_group/passive_effect"

But I'm running into brickwall again with other ideas :/

trying to revert there weird choice to increase material amount as one get better at making things, and been trying everything I can think of.

Currently ended up with this code, with the thrownspeariron as a test to see if even the syntax was correct, but it was not applied :(

 

<set xpath="/recipies/recipe[@name=meleeThrownSpearIron]/effect_group/passive_effect[@name=CraftingIngredientCount' and @value='.5,2.5]/@value">2.5,.5</set>

 

hoping to replace the meleeThrownSpearIron with a wildcard (if that's doable?) to fix all those recipies, but can't get the syntax right.

Link to post
Share on other sites

Hello everyone, help me deal with the icons for items. I’m doing a mod on 18.2, I add an arrow object, in the ItemIcons folder there is a picture 160 * 160 in .png format

The game has an item, there is a recipe, but there is no icon that I made for this item. What's wrong, with the code that I wrote, here it is.

 

<item name="ammoArrowStonePaper">

<property name="CustomIcon" value="#@modfolder:ItemIcons/ammoArrowStonePaper.png" />

<!--<property name="CustomIcon" value="#@modfolder:Textures/iconsItem/ammoArrowStonePaper.png" />-->

I tried to put it in another folder, but still there is no icon in the game

tell me what is wrong or what needs to be done!

Link to post
Share on other sites
How do i add a Battery to the Junk Turret recipe? I tried but ended up with double recipes lol

 

what does your XML look like?

 

- - - Updated - - -

 

Hello everyone, help me deal with the icons for items. I’m doing a mod on 18.2, I add an arrow object, in the ItemIcons folder there is a picture 160 * 160 in .png format

The game has an item, there is a recipe, but there is no icon that I made for this item. What's wrong, with the code that I wrote, here it is.

 

<item name="ammoArrowStonePaper">

<property name="CustomIcon" value="#@modfolder:ItemIcons/ammoArrowStonePaper.png" />

<!--<property name="CustomIcon" value="#@modfolder:Textures/iconsItem/ammoArrowStonePaper.png" />-->

I tried to put it in another folder, but still there is no icon in the game

tell me what is wrong or what needs to be done!

 

I think it builds an atlas, so your custom icon would probably be something like

 

<property name="CustomIcon" value="ammoArrowStonePaper" />

 

if you name you item as ammoArrowStonePaper, it should also work without custom icon.

Link to post
Share on other sites
<configs>

<append xpath="/recipes">

<recipe name="gunJunkTurret" count="1" craft_area="workbench" tags="learnable,perkTurrets">

<ingredient name="gunJunkTurretParts" count="4"/>

<ingredient name="resourceForgedIron" count="40"/>

 

<ingredient name="carBattery" count="1"/>

 

<ingredient name="resourceDuctTape" count="1"/>

<ingredient name="resourceScrapPolymers" count="10"/>

<ingredient name="resourceSpring" count="10"/>

<effect_group>

<passive_effect name="CraftingIngredientCount" level="2,6" operation="perc_add" value=".5,2.5" tags="gunJunkTurretParts,resourceForgedIron,resourceDuctTape,resourceScrapPolymers,resourceSpring"/>

</effect_group>

</recipe>

</append>

</configs>

 

 

It works, but the vanilla recipe is there too. I just want to "insert" a battery into the existing vanilla recipe

Edited by wolverine576 (see edit history)
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...