Jump to content

XPath Modding Explanation Thread


sphereii
 Share

Recommended Posts

thank you.

 

I'm looking to take it out of windows xml to add a new one in. sorry for the confusion.

 

Filename: Mods/YourMod/Config/XUi/windows.xml

<configs>
    <remove xpath="/windows/window[@name='HUDLeftStatBars']" />
    <append xpath="/windows" >
              <window name="HUDLeftStatBars" >

               </window>
   </append>
</configs>

Link to comment
Share on other sites

Yup, using <set

 

<set xpath="items/item[@name='toolsPickAxe']/property[@name='Meshfile']/@value">#@modfolder:Resouces/meleeToolPickaxeSteel.unity3d?meleeToolPickaxeSteel</set>

 

that's assuming you have a Mods/YourFolder/Resources/meleeToolPickAxeSteel.unity3d exists.

 

so the "toolsPickAxe" part in this code is the name of the item, right ?

 

so if it is called "meleeToolPickaxeSteel" the code has to be this :

 

<set xpath="items/item[@name='meleeToolPickaxeSteel']/property[@name='Meshfile']/@value">#@modfolder:Resouces/meleeToolPickaxeSteel.unity3d?meleeToolPickaxeSteel</set>

Link to comment
Share on other sites

so the "toolsPickAxe" part in this code is the name of the item, right ?

 

so if it is called "meleeToolPickaxeSteel" the code has to be this :

 

<set xpath="items/item[@name='meleeToolPickaxeSteel']/property[@name='Meshfile']/@value">#@modfolder:Resouces/meleeToolPickaxeSteel.unity3d?meleeToolPickaxeSteel</set>

 

Whatever it is in the XML. I usually not in a position to cross reference the particular names; they are usually just to get you started.

Link to comment
Share on other sites

Whatever it is in the XML. I usually not in a position to cross reference the particular names; they are usually just to get you started.

 

 

i use this code

 

	<append xpath="/items">

<set xpath="items/item[@name='meleeToolPickaxeSteel']/property[@name='Meshfile']/@value">#@modfolder:Resouces/meleeToolPickaxeSteel.unity3d?meleeToolPickaxeSteel</set>

</append>

 

but it dont work, i have NO error in the log but ingame is still the same old model

Link to comment
Share on other sites

what's up all, I need some help, im trying to have the hunting rifle 3 rounds in stud of 1, and add new ammo.

I have the ammo in but cant get it to load in this is what im using. does these need to go at the top of the xml?

 

<set xpath="/items/item[@name='gunHuntingRifle']/property[@class='Action1']/passive_effect[@name='MagazineSize'][@value='1']/@value">3</set>
<set xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='ammo9mmBullet,ammo9mmBulletSteel']/@value">ammo9mmBullet,ammo9mmBulletSteel,ammo9mmBulletExp</set>

-- up date --

got the ammo to load but when I spawned in a zombie I couldn't move, I died and I could move again but my fire Butten was reload and no ammo was being loaded. here is my ammo code.

 

 

<item name="ammo9mmBulletExp">
<property name="DisplayType" value="ammoBullet"/>
<property name="HoldType" value="45"/>
<property name="Meshfile" value="Items/Misc/sackPrefab"/>
<property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab"/>
<property name="Material" value="Mbrass"/>
<property name="Stacknumber" value="500"/> <!-- STK ammo -->
<property name="CraftingSkillGroup" value="craftSkillGuns"/>
<property name="EconomicValue" value="14"/>
<property name="Group" value="Ammo/Weapons"/>
<property class="Action1">
	<property name="Class" value="Projectile"/>
	<property name="Gravity" value="-7"/>
	<property name="Explosion.ParticleIndex" value="4"/> <!-- which Prefab/particle is used -->
	<property name="Explosion.RadiusBlocks" value="2"/> <!-- damage radius for blocks -->
	<property name="Explosion.BlockDamage" value="75"/> <!-- damage for blocks in the center of the explosion -->
	<property name="Explosion.RadiusEntities" value="2"/> <!-- damage radius for entities -->
	<property name="Explosion.EntityDamage" value="50"/> <!-- damage for entities in the center of the explosion. Zombies take 2x this damage. -->
       <property name="Explosion.DamageBonus.stone" value="15"/>
	<property name="Explosion.DamageBonus.metal" value="7"/>
	<property name="Explosion.DamageBonus.earth" value="25"/> <!-- should work? -->
	<property name="Explosion.DamageBonus.wood" value="35"/>
	<property name="Explosion.DamageBonus.water" value="0"/>
</property>
<property name="CraftingSkillGroup" value="craftSkillScience"/>
<property name="Group" value="Ammo/Weapons"/>
<effect_group name="Base Effects" tiered="false">
	<passive_effect name="EntityDamage" operation="base_set" value="25"/>
	<passive_effect name="BlockDamage" operation="base_set" value="7"/>
	<passive_effect name="ProjectileVelocity" operation="base_set" value="60"/>
	<display_value name="ExRadius" value="5" />
</effect_group>
</item>

Edited by dragonslayer770
up date (see edit history)
Link to comment
Share on other sites

i use this code

 

	<append xpath="/items">

<set xpath="items/item[@name='meleeToolPickaxeSteel']/property[@name='Meshfile']/@value">#@modfolder:Resouces/meleeToolPickaxeSteel.unity3d?meleeToolPickaxeSteel</set>

</append>

 

but it dont work, i have NO error in the log but ingame is still the same old model

 

I think you need to move <set> outside of <append></append>, else you are telling the game to add the <set> string to the xml file instead of changing the given values in the file :)

 

 <set xpath="/items/item[@name='meleeToolPickaxeSteel']/property[@name='Meshfile']/@value">#@modfolder:Resouces/meleeToolPickaxeSteel.unity3d?meleeToolPickaxeSteel</set>

<append xpath="/items">
<!-- whatever you want to add goes here, else the append command is not needed-->
</append>

 

You were also missing a / at <set xpath="items/item...> :)

Link to comment
Share on other sites

Can anyone tell me what's wrong with this xpath please?

 

<set xpath="/progression/level/@exp_to_level">100</set>

 

If it's obvious I apologise. The 100 shows in black text, the rest shows purple (except xpath which is in red). It seems to me like it should work but... no. Aim: trying to reduce the experience needed to level up.

 

Any help appreciated.

Link to comment
Share on other sites

Can anyone tell me what's wrong with this xpath please?

 

<set xpath="/progression/level/@exp_to_level">100</set>

 

If it's obvious I apologise. The 100 shows in black text, the rest shows purple (except xpath which is in red). It seems to me like it should work but... no. Aim: trying to reduce the experience needed to level up.

 

Any help appreciated.

 

Yup, that looks right. Are you getting an error or the change isn't applied?

Link to comment
Share on other sites

Is it possible to use append to add one node after an existing one? I managed to do what I want using insertafter, but Im curious after I failed with append.

original

<recipe name="woodFrameBlock" count="1">
<ingredient name="resourceWood" count="2"/>
</recipe>

 

lets say I want add another ingredient after wood. I feel it's possible to use append, but Im failing to point the right path I guess

 

<append xpath="/recipes/recipe[@name='woodFrameBlock']/@recipe">
<ingredient name="resourceNail" count="1"/>
</append>

 

This will add the code inside recipe node, so its not what I want. If I change to @ingredient, it will add to the wood node. so I tried /ingredient/ without @, because its not inside any of the existing nodes, but it doesnt work.

Link to comment
Share on other sites

Hi Sphereii

I've been working on some mods and got a few working but I'm having issues with this one and I'm wondering if you could help point out what I've done wrong please.

Here is my xpath:

https://pastebin.com/KukxTWSe

 

Ignore the custom block types I've added, my test launches on return errors with biomes.xml and the blocks have tested fine.

 

This is my first time trying to insert an entire sub-node within a node via xpath append and i'm unsure if it's the correct way, it's most likely the issue.

 

All my other appends that add entire new nodes work fine.

Link to comment
Share on other sites

Hi Sphereii

I've been working on some mods and got a few working but I'm having issues with this one and I'm wondering if you could help point out what I've done wrong please.

Here is my xpath:

https://pastebin.com/KukxTWSe

 

Ignore the custom block types I've added, my test launches on return errors with biomes.xml and the blocks have tested fine.

 

This is my first time trying to insert an entire sub-node within a node via xpath append and i'm unsure if it's the correct way, it's most likely the issue.

 

All my other appends that add entire new nodes work fine.

 

In notepad++, you can use XML Tools to pretty print your XML. Then you'd see your XML like this:

 

	<subbiome prob="0.1551">
		<!-- Ore Sub Biome: Copper -->
		<layers>
			<layer depth="4" blockname="terrSnow"/>
			<resource blockname="Gravel_Plus_Copper" prob="0.071" rwgGenerationType="all"/>
			<layer depth="3" blockname="terrDirt">
				<resource blockname="Gravel_Plus_Copper" prob="0.811" rwgGenerationType="all"/>
			</layer>

 

 

You can see your layer depth"4" blockname="terrSnow" closes it's layer. So that resource blockname is kind of just floating around.

Link to comment
Share on other sites

In notepad++, you can use XML Tools to pretty print your XML. Then you'd see your XML like this:

 

	<subbiome prob="0.1551">
		<!-- Ore Sub Biome: Copper -->
		<layers>
			<layer depth="4" blockname="terrSnow"/>
			<resource blockname="Gravel_Plus_Copper" prob="0.071" rwgGenerationType="all"/>
			<layer depth="3" blockname="terrDirt">
				<resource blockname="Gravel_Plus_Copper" prob="0.811" rwgGenerationType="all"/>
			</layer>

 

 

You can see your layer depth"4" blockname="terrSnow" closes it's layer. So that resource blockname is kind of just floating around.

 

Yeah I know, that's how all the default sub-biomes are in the defualt A17b209 biomes.xml right now. It's not the cause of the issue.

What I am asking is, does my xpath append put these sub-biome nodes in the correct place of the biomes.xml?

<append xpath="/biomes/biome[@name='snow']">

Link to comment
Share on other sites

Yeah I know, that's how all the default sub-biomes are in the defualt A17b209 biomes.xml right now. It's not the cause of the issue.

What I am asking is, does my xpath append put these sub-biome nodes in the correct place of the biomes.xml?

<append xpath="/biomes/biome[@name='snow']">

 

You are missing the top level /worldgeneration xpath="/worldgeneration/biomes/biome[@name=snow]

Link to comment
Share on other sites

Does anyone know if you can xpath into the Prefabs folder and change stuff in the xml files? Like is it possible?

 

No, unfortunately not. We are hoping to be able to load prefabs from the Mod folder eventually.

 

What were you trying to do in the prefab xml?

Link to comment
Share on other sites

No, unfortunately not. We are hoping to be able to load prefabs from the Mod folder eventually.

 

What were you trying to do in the prefab xml?

 

Ah damn :/ Yeah one can only hope for that added functionality.

 

I was trying to change what zones the vanilla prefabs can spawn in, a workaround to temp add back in all the larger buildings.

Atleast I was trying to do it through xpath.

Link to comment
Share on other sites

I'm trying to increase the probability of commonBooks spawning in certain containers. My xpath:

 

<loot>

 

<set xpath="/lootcontainers/lootcontainer[@id=14]/item[@group=books]/@prob=">0.4</set>

 

</loot>

 

I keep getting errors on trying to load the game. Before I grab my output log and all that, can someone just check I haven't made any silly errors? It looks like it should work but isn't.

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
 Share

×
×
  • Create New...