Jump to content
sphereii

XPath Modding Explanation Thread

Recommended Posts

Running into a slight headache. Anyone know WHY im getting that extra </item> tag at the end of this code?

 

<lootcontainer id="36" count="0,2" size="4,3" sound_open="UseActions/open_suitcase" sound_close="UseActions/close_suitcase" loot_quality_template="baseTemplate">
   <item name="drinkJarBoiledWater" count="1" prob="0.15"><!--Attribute "count" replaced by: "JaxTeller718_LessWaterInLoot"--></item>
   <item group="cannedfood" prob="0.5" />
   <item group="junk" />
   <item name="meleeToolFlashlight02" prob="0.1" />
   <item group="medicine" prob="0.1" />
   <item group="weaponsBasicGuns+ammo" prob="0.03" />
   <item group="weaponsMelee" prob="0.03" />
   <item group="ammo" />
</lootcontainer>

 

here is the xpath im using for that

 

<set xpath="/lootcontainers/lootcontainer[@id='36']/item[@name='drinkJarBoiledWater']/@count">1</set>

Share this post


Link to post
Share on other sites

How do i add an item to a lootgroup?

 

I want to add the fuellog to loot group Tools, i came up with this

 

<config>

<set xpath="/lootgroups/lootgroup[@name='tools']/item[@name='fuellog']/@count">1</set>

</config>

Edited by wolverine576 (see edit history)

Share this post


Link to post
Share on other sites
Running into a slight headache. Anyone know WHY im getting that extra </item> tag at the end of this code?

 

<lootcontainer id="36" count="0,2" size="4,3" sound_open="UseActions/open_suitcase" sound_close="UseActions/close_suitcase" loot_quality_template="baseTemplate">
   <item name="drinkJarBoiledWater" count="1" prob="0.15"><!--Attribute "count" replaced by: "JaxTeller718_LessWaterInLoot"--></item>
   <item group="cannedfood" prob="0.5" />
   <item group="junk" />
   <item name="meleeToolFlashlight02" prob="0.1" />
   <item group="medicine" prob="0.1" />
   <item group="weaponsBasicGuns+ammo" prob="0.03" />
   <item group="weaponsMelee" prob="0.03" />
   <item group="ammo" />
</lootcontainer>

 

here is the xpath im using for that

 

<set xpath="/lootcontainers/lootcontainer[@id='36']/item[@name='drinkJarBoiledWater']/@count">1</set>

 

Compare it to these two examples:

<set xpath="/lootcontainers/lootcontainer[@id='62']/@size">7,6</set>

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

 

I'm guessing the /item, either needs to be removed or named @item, but I don't really know this stuff yet.

Edited by Guppycur (see edit history)

Share this post


Link to post
Share on other sites
Running into a slight headache. Anyone know WHY im getting that extra </item> tag at the end of this code?

 

<lootcontainer id="36" count="0,2" size="4,3" sound_open="UseActions/open_suitcase" sound_close="UseActions/close_suitcase" loot_quality_template="baseTemplate">
   <item name="drinkJarBoiledWater" count="1" prob="0.15"><!--Attribute "count" replaced by: "JaxTeller718_LessWaterInLoot"--></item>
   <item group="cannedfood" prob="0.5" />
   <item group="junk" />
   <item name="meleeToolFlashlight02" prob="0.1" />
   <item group="medicine" prob="0.1" />
   <item group="weaponsBasicGuns+ammo" prob="0.03" />
   <item group="weaponsMelee" prob="0.03" />
   <item group="ammo" />
</lootcontainer>

 

here is the xpath im using for that

 

<set xpath="/lootcontainers/lootcontainer[@id='36']/item[@name='drinkJarBoiledWater']/@count">1</set>

 

That is valid XML, although it may look a bit weird. The modding hooks inserts that comment after each change.

 

<item name="drinkJarBoiledWater" count="10" prob="0.15" />

 

is the same as

 

<item name="drinkJarBoiledWater" count="10" prob="0.15" > </item>

 

Just on a single line xml node, a short cut can be used.

 

If it's causing a parsing error, than that is a bug. But otherwise, I'd expect that line to be functionally the same as the others.

 

- - - Updated - - -

 

How do i add an item to a lootgroup?

 

I want to add the fuellog to loot group Tools, i came up with this

 

<config>

<set xpath="/lootgroups/lootgroup[@name='tools']/item[@name='fuellog']/@count">1</set>

</config>

 

If you want to add a new line, it'd be append

 

<config>
   <append xpath="/lootgroups/lootgroup[@name='tools']">
       <item name="fuellog"' count="1" />
   </append>
</config>

Share this post


Link to post
Share on other sites

Is this right to add fuellog to multiple groups?

 

<config>

   <append xpath="/lootgroups/lootgroup[@name='tools']">
       <item name="fuellog"' count="1" />


   <append xpath="/lootgroups/lootgroup[@name='junk']">
       <item name="fuellog"' count="1" />

   </append>	

</config>

Share this post


Link to post
Share on other sites
Is this right to add fuellog to multiple groups?

 

<config>

   <append xpath="/lootgroups/lootgroup[@name='tools']">
       <item name="fuellog"' count="1" />


   <append xpath="/lootgroups/lootgroup[@name='junk']">
       <item name="fuellog"' count="1" />

   </append>	

</config>

 

Close. You'd need to </append> the first one, before you start working on a different xpath command.

Share this post


Link to post
Share on other sites

So each new addition needs closed?

 

 

<config>
   <append xpath="/lootgroups/lootgroup[@name='tools']">
       <item name="fuellog"' count="1" />
  </append>

   <append xpath="/lootgroups/lootgroup[@name='junk']">
       <item name="fuellog"' count="1" />
   </append>	

</config>

Share this post


Link to post
Share on other sites
So each new addition needs closed?

 

 

<config>
   <append xpath="/lootgroups/lootgroup[@name='tools']">
       <item name="fuellog"' count="1" />
  </append>

   <append xpath="/lootgroups/lootgroup[@name='junk']">
       <item name="fuellog"' count="1" />
   </append>	

</config>

 

Yup! The append looks good.

 

I think your xpath may be a bit off.

 

xpath="/lootcontainers/lootgroup[@name=tools]" may be more accurate, since the loogroup is under the <lootcontainers> node.

Share this post


Link to post
Share on other sites
Yup! The append looks good.

 

I think your xpath may be a bit off.

 

xpath="/lootcontainers/lootgroup[@name=tools]" may be more accurate, since the loogroup is under the <lootcontainers> node.

 

Now im confusd. Containers and groups are in different sections? Add the item to the group, and it goes into the containers?

Share this post


Link to post
Share on other sites

getting error in loot

 

2018-11-23T10:06:17 34.678 ERR Failed loading and parsing XML (loot.xml):
2018-11-23T10:06:17 34.679 EXC Unexpected token. Name is required here.  Line 3, position 29.
XmlException: Unexpected token. Name is required here.  Line 3, position 29.
 at Mono.Xml2.XmlTextReader.ReadAttributes (Boolean isXmlDecl) [0x00000] in <filename unknown>:0 
 at Mono.Xml2.XmlTextReader.ReadStartTag () [0x00000] in <filename unknown>:0 
 at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0 
 at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
 at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.Load (System.Xml.XmlReader xmlReader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.LoadXml (System.String xml) [0x00000] in <filename unknown>:0 
 at XmlFile.toXml (System.String _data, System.String _filename) [0x00000] in <filename unknown>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Logger:masterLogException(Exception)
Logger:Exception(Exception)
Log:Exception(Exception)
XmlFile:toXml(String, String)
XmlFile:.ctor(String, String, String)
XmlPatcher:LoadAndPatchConfig(String)
<loadSingleXml>c__Iterator1:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

(Filename:  Line: -1)

Share this post


Link to post
Share on other sites
Now im confusd. Containers and groups are in different sections? Add the item to the group, and it goes into the containers?

 

In loot.xml, the <lootcontainers> is the root XML node.

 

M7bQMCl.png

Share this post


Link to post
Share on other sites
getting error in loot

 

2018-11-23T10:06:17 34.678 ERR Failed loading and parsing XML (loot.xml):
2018-11-23T10:06:17 34.679 EXC Unexpected token. Name is required here.  Line 3, position 29.
XmlException: Unexpected token. Name is required here.  Line 3, position 29.
 at Mono.Xml2.XmlTextReader.ReadAttributes (Boolean isXmlDecl) [0x00000] in <filename unknown>:0 
 at Mono.Xml2.XmlTextReader.ReadStartTag () [0x00000] in <filename unknown>:0 
 at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0 
 at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
 at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.Load (System.Xml.XmlReader xmlReader) [0x00000] in <filename unknown>:0 
 at System.Xml.XmlDocument.LoadXml (System.String xml) [0x00000] in <filename unknown>:0 
 at XmlFile.toXml (System.String _data, System.String _filename) [0x00000] in <filename unknown>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Logger:masterLogException(Exception)
Logger:Exception(Exception)
Log:Exception(Exception)
XmlFile:toXml(String, String)
XmlFile:.ctor(String, String, String)
XmlPatcher:LoadAndPatchConfig(String)
<loadSingleXml>c__Iterator1:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

(Filename:  Line: -1)

 

Can you post your full xml snippet?

Share this post


Link to post
Share on other sites

The full error or modlet?

 

 

<config>
   <append xpath="/lootcontainers/lootgroup[@name='tools']">
       <item name="fuellog"' count="1" />
  </append>

   <append xpath="/lootcontainers/lootgroup[@name='junk']">
       <item name="fuellog"' count="1" />
   </append>	

</config>

Share this post


Link to post
Share on other sites
The full error or modlet?

 

 

<config>
   <append xpath="/lootcontainers/lootgroup[@name='tools']">
       <item name="fuellog"' count="1" />
  </append>

   <append xpath="/lootcontainers/lootgroup[@name='junk']">
       <item name="fuellog"' count="1" />
   </append>	

</config>

 

Found it, I think. You have an extra ' after "fuellog".

Share this post


Link to post
Share on other sites

Now im getting error fuellog not found.

 

Full error log

 

heres my Items

 

<configs>
    <append xpath="/items">

           	<item name="fuelLog">

                   <property name="Meshfile" value="Items/Misc/sackPrefab"/>
                   <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab"/>
   	               <property name="Material" value="Mwood"/>
                   <property name="HoldType" value="45"/>
	               <property name="Stacknumber" value="50" />
				   	<property name="Weight" value="5"/>
   	               <property name="SellableToTrader" value="true"/>
	               <property name="EconomicValue" value="34"/>
	               <property name="FuelValue" value="580" />
                   <property name="Group" value="Resources,Basics"/>
                   <property name="CraftingSkillGroup" value="craftSkillScience"/>
				   <property name="CraftingIngredientTime" value="0.25"/>


             </item>

	</append>
</configs>

 

recipes

 

<configs>
    <append xpath="/recipes">

               <recipe name="fuelLog" count="1">
                  <ingredient name="resourceWood" count="20"/>
                  <ingredient name="resourceTallow" count="1" />
               </recipe>

	</append>
</configs>

 

loot

 

<config>
   <append xpath="/lootcontainers/lootgroup[@name='tools']">
       <item name="fuellog" count="1" />
  </append>

   <append xpath="/lootcontainers/lootgroup[@name='junk']">
       <item name="fuellog" count="1" />
   </append>	

</config>

 

Ok i fixed it, i didnt have the 2nd L capitalized

Edited by wolverine576 (see edit history)

Share this post


Link to post
Share on other sites
Now im getting error fuellog not found.

 

Full error log

 

heres my Items

 

<configs>
    <append xpath="/items">

           	<item name="fuelLog">

                   <property name="Meshfile" value="Items/Misc/sackPrefab"/>
                   <property name="DropMeshfile" value="Items/Misc/sack_droppedPrefab"/>
   	               <property name="Material" value="Mwood"/>
                   <property name="HoldType" value="45"/>
	               <property name="Stacknumber" value="50" />
				   	<property name="Weight" value="5"/>
   	               <property name="SellableToTrader" value="true"/>
	               <property name="EconomicValue" value="34"/>
	               <property name="FuelValue" value="580" />
                   <property name="Group" value="Resources,Basics"/>
                   <property name="CraftingSkillGroup" value="craftSkillScience"/>
				   <property name="CraftingIngredientTime" value="0.25"/>


             </item>

	</append>
</configs>

 

recipes

 

<configs>
    <append xpath="/recipes">

               <recipe name="fuelLog" count="1">
                  <ingredient name="resourceWood" count="20"/>
                  <ingredient name="resourceTallow" count="1" />
               </recipe>

	</append>
</configs>

 

loot

 

<config>
   <append xpath="/lootcontainers/lootgroup[@name='tools']">
       <item name="fuellog" count="1" />
  </append>

   <append xpath="/lootcontainers/lootgroup[@name='junk']">
       <item name="fuellog" count="1" />
   </append>	

</config>

 

Ok i fixed it, i didnt have the 2nd L capitalized

 

Case matters. Mind your "L" in log. Make sure it's consistent.

Share this post


Link to post
Share on other sites

ok Im reading it but I just dont get it

 

can someone show me a way to add an xpath mod that will change this line in items.xml

<!-- jar from cooking food <property name="Create_item" value="drinkJarEmpty"/> -->

 

to this

 

<property name="Create_item" value="drinkJarEmpty"/>

Share this post


Link to post
Share on other sites

Here is a snippet that I used to add it to various food types. I originally did it for each recipe individually, but you can chain some 'or' commands in the name section to add them all at once.

 

 

<append xpath="/items/item[@name=foodBoiledMeat] /property[@class=Action0]">

 

<property name="Create_item" value="drinkJarEmpty"/>

 

</append>

Share this post


Link to post
Share on other sites
Here is a snippet that I used to add it to various food types. I originally did it for each recipe individually, but you can chain some 'or' commands in the name section to add them all at once.

 

 

<append xpath="/items/item[@name=foodBoiledMeat] /property[@class=Action0]">

 

<property name="Create_item" value="drinkJarEmpty"/>

 

</append>

 

ok but could you tell me how to do that like I have no clue what Im doing LOL

where do I put that

what file name

and how do I apply it to all items with that line

Share this post


Link to post
Share on other sites
ok but could you tell me how to do that like I have no clue what Im doing LOL

where do I put that

what file name

and how do I apply it to all items with that line

 

Be more specific. Where do you want the change?

 

You'd probably have to use append to add the line of code to the drinks you want the jar back added to.

Edited by wolverine576 (see edit history)

Share this post


Link to post
Share on other sites

Noob question: Are you able to do a simple operation on a value? From everything I've seen has been hard replacements, but no arithmetic examples.

 

For example:

Value = 10, want to increase by 20% 

<set xpath="/something/somethingelse/@value">*1.2</set>

Will this result in 12?

Share this post


Link to post
Share on other sites
Noob question: Are you able to do a simple operation on a value? From everything I've seen has been hard replacements, but no arithmetic examples.

 

For example:

Value = 10, want to increase by 20% 

<set xpath="/something/somethingelse/@value">*1.2</set>

Will this result in 12?

 

No sorry, there's no math operation in the current xpath system. xpath is just a method of finding stuff in the XML. The game uses the xpath to make the appropriate changes.

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...