Jump to content

XML "set" syntax


Dimpy

Recommended Posts

Hey, I've been trying to use an adapted version of the Tutorial mod to make small stones into a tool, but I think I have been getting the syntax wrong. Can anyone help fix this code?

 

 

 

<configs>

<!-- This tells SDX to add to the items.xml -->

<config name="items">

<!-- This tells SDX to add the following item to the bottom of the item list -->

<set xpath= "/items/item[@name=rockSmall]">

 

<property name="Meshfile" value="Items/Crafting/rock_smallPrefab"/>

<property name="Material" value="stone"/>

<property name="HoldType" value="40"/>

<property name="Stacknumber" value="5000"/> <!-- STK resource -->

<property name="RepairAmount" value="300"/>

<property name="Weight" value="5"/>

<property name="EconomicValue" value="5"/>

<property name="EconomicBundleSize" value="50"/>

<property class="Action0">

<property name="Class" value="Melee"/>

<property name="Delay" value="1.1"/>

<property name="Range" value="2.5"/>

<property name="DamageEntity" value="5"/>

<property name="DamageBlock" value="15"/>

<property name="Sphere" value="0.1"/>

<property name="Block_range" value="2.5"/>

<property name="Sound_start" value="swoosh"/>

<property name="Stamina_usage" value="2.7"/>

 

<property name="DamageBonus.head" value="3.5"/>

<property name="DamageBonus.glass" value="0.42"/>

<property name="DamageBonus.wood" value="0.6"/>

<property name="DamageBonus.earth" value="0.3083"/>

<property name="DamageBonus.stone" value="0.625"/>

<property name="DamageBonus.metal" value="0.4167"/>

<property name="DamageBonus.organic" value="1.3"/>

<property name="ToolCategory.harvestingTools" value="1" param1="1"/>

<property name="ToolCategory.Butcher" value="0.5" param1="3.5"/>

<property name="Sound_harvesting" value="open_animal" param1="organic" />

 

<property name="ActionExp" value="0.5"/>

 

</property>

 

 

<property class="Action1"> <!-- right click -->

<property name="Class" value="ThrowAway"/>

<property name="Delay" value="1.2"/>

<property name="Throw_strength_default" value="8"/>

<property name="Throw_strength_max" value="25"/>

<property name="Max_strain_time" value="1.5"/>

<property name="Sound_start" value="swoosh"/>

</property>

 

 

<property name="ThrowableDecoy" value="true"/>

<property name="DropScale" value="3"/>

<property name="Group" value="Resources"/>

<property name="CraftingIngredientTime" value="0.5"/>

 

</set>

</config>

 

 

 

</configs>

Link to comment
Share on other sites

Hey, I've been trying to use an adapted version of the Tutorial mod to make small stones into a tool, but I think I have been getting the syntax wrong. Can anyone help fix this code?

 

 

 

<configs>

<!-- This tells SDX to add to the items.xml -->

<config name="items">

<!-- This tells SDX to add the following item to the bottom of the item list -->

<set xpath= "/items/item[@name=rockSmall]">

 

<property name="Meshfile" value="Items/Crafting/rock_smallPrefab"/>

<property name="Material" value="stone"/>

<property name="HoldType" value="40"/>

<property name="Stacknumber" value="5000"/> <!-- STK resource -->

<property name="RepairAmount" value="300"/>

<property name="Weight" value="5"/>

<property name="EconomicValue" value="5"/>

<property name="EconomicBundleSize" value="50"/>

<property class="Action0">

<property name="Class" value="Melee"/>

<property name="Delay" value="1.1"/>

<property name="Range" value="2.5"/>

<property name="DamageEntity" value="5"/>

<property name="DamageBlock" value="15"/>

<property name="Sphere" value="0.1"/>

<property name="Block_range" value="2.5"/>

<property name="Sound_start" value="swoosh"/>

<property name="Stamina_usage" value="2.7"/>

 

<property name="DamageBonus.head" value="3.5"/>

<property name="DamageBonus.glass" value="0.42"/>

<property name="DamageBonus.wood" value="0.6"/>

<property name="DamageBonus.earth" value="0.3083"/>

<property name="DamageBonus.stone" value="0.625"/>

<property name="DamageBonus.metal" value="0.4167"/>

<property name="DamageBonus.organic" value="1.3"/>

<property name="ToolCategory.harvestingTools" value="1" param1="1"/>

<property name="ToolCategory.Butcher" value="0.5" param1="3.5"/>

<property name="Sound_harvesting" value="open_animal" param1="organic" />

 

<property name="ActionExp" value="0.5"/>

 

</property>

 

 

<property class="Action1"> <!-- right click -->

<property name="Class" value="ThrowAway"/>

<property name="Delay" value="1.2"/>

<property name="Throw_strength_default" value="8"/>

<property name="Throw_strength_max" value="25"/>

<property name="Max_strain_time" value="1.5"/>

<property name="Sound_start" value="swoosh"/>

</property>

 

 

<property name="ThrowableDecoy" value="true"/>

<property name="DropScale" value="3"/>

<property name="Group" value="Resources"/>

<property name="CraftingIngredientTime" value="0.5"/>

 

</set>

</config>

 

 

 

</configs>

 

The SDX <set> allows you to change individual attributes that already exists. It's a single line.

 

<set xpath="/items/item/[@name='rockSmall']/property[@name='HoldType']/@value">40</set>

 

To add new attributes and properties, you'll wand to use <append>

 

<append xpath="/items/item/[@name='rockSmall']">
    <property name="ThrowableDecoy" value="true"/>
    <property name="DropScale" value="3"/>
    <property name="CraftingIngredientTime" value="0.5"/>
</append>

 

By the looks of it, to change the smallrock to a weapon, you'll need a combination of <set> to change existing values, and <append> to add new lines.

 

It'd look similar to this, with more <set> to change all the other non-existing values.

<set xpath="/items/item/[@name='rockSmall']/property[@name='HoldType']/@value">40</set>
<append xpath="/items/item/[@name='rockSmall']">
    <property name="ThrowableDecoy" value="true"/>
    <property name="DropScale" value="3"/>
    <property name="CraftingIngredientTime" value="0.5"/>
</append>

 

Another way you can do it, is by removing the small rock, using the <remove> xpath command. Then <append> an entirely new item with the same name.

<remove xpath="/items/item/[@name='rockSmall']" />
<append xpath="/items" >
   <item name="smallRock" >
      <all other values>
  </item>
</append>

Link to comment
Share on other sites

Yeah, I didn't realize that set was single line only. I tried the remove and append strategy, but I got an error in the build menu that said:

 

Apply mod config patch: Primative building

Applying patch: SDX0.7.1/Targets\7DaysToDie\Mods\Dimpy's Mod\Config\stoneTool2.xml...

ERROR: Expression must evaluate to a node-set.

EVENT: Run sub task: Run Xml Patcher mod scripts

WARN: No assembly from BuildAndRunPatchModsTask

 

 

Here is my new code:

 

<configs>
<config name = "items">
	<remove xpath="/items/item/[@name='rockSmall']" />
	<append xpath="/items" >
		<item id="190" name="rockSmall"> <!-- scrap material -->	
			<property name="Meshfile" value="Items/Crafting/rock_smallPrefab"/>
			<property name="Material" value="stone"/>
			<property name="HoldType" value="40"/>
			<property name="Stacknumber" value="5000"/> <!-- STK resource -->
			<property name="RepairAmount" value="300"/>
			<property name="Weight" value="5"/>
			<property name="EconomicValue" value="5"/>
			<property name="EconomicBundleSize" value="50"/>
			<property class="Action0">
				<property name="Class" value="Melee"/>
				<property name="Delay" value="1.1"/>
				<property name="Range" value="2.5"/>
				<property name="DamageEntity" value="5"/>
				<property name="DamageBlock" value="15"/>
				<property name="Sphere" value="0.1"/>
				<property name="Block_range" value="2.5"/>
				<property name="Sound_start" value="swoosh"/>
				<property name="Stamina_usage" value="2.7"/>

				<property name="DamageBonus.head" value="3.5"/>
				<property name="DamageBonus.glass" value="0.42"/>
				<property name="DamageBonus.wood" value="0.6"/>
				<property name="DamageBonus.earth" value="0.3083"/>
				<property name="DamageBonus.stone" value="0.625"/>
				<property name="DamageBonus.metal" value="0.4167"/>
				<property name="DamageBonus.organic" value="1.3"/>
				<property name="ToolCategory.harvestingTools" value="1" param1="1"/>
				<property name="ToolCategory.Butcher" value="0.5" param1="3.5"/>
				<property name="Sound_harvesting" value="open_animal" param1="organic" />

				<property name="ActionExp" value="0.5"/>

			</property>


			<property class="Action1"> <!-- right click -->
				<property name="Class" value="ThrowAway"/>
				<property name="Delay" value="1.2"/>
				<property name="Throw_strength_default" value="8"/>
				<property name="Throw_strength_max" value="25"/>
				<property name="Max_strain_time" value="1.5"/>
				<property name="Sound_start" value="swoosh"/>
			</property>


			<property name="ThrowableDecoy" value="true"/>
			<property name="DropScale" value="3"/>
			<property name="Group" value="Resources"/>
			<property name="CraftingIngredientTime" value="0.5"/>

		</item>
	</append>
</config>

</configs>

Link to comment
Share on other sites

Think the last / is wrong in the remove, AFAIK it should be "/items/item[@name=rockSmall]".

Also, set does allow multiple elements to be set, but it will always replace the whole element's contents with whatever you have which might not always be desired. In this case I'm pretty sure though that using a single set-statement (with your XPATH value) should work instead of remove+append.

 

/EDIT:

Oh heh, should've refreshed before replying in a tab that was open for quite some time now :D

Link to comment
Share on other sites

Okay, I removed the backslash, and now the stone has disappeared from the creative menu, rather than being the vanilla stone. Am I missing values in the append code that are needed for it to appear there?

Link to comment
Share on other sites

I just pasted the original XML data of the small stone into the mod and it also works fine. I'm guessing it has to do with the settings. Can anyone see problems with the settings I had in the code I posted preveiosly?

 

Mod with vanilla stone settings that works:

 

<configs>
<config name = "items">
	<remove xpath="/items/item[@name='rockSmall']" />
	<append xpath="/items" >
		<item id="190" name="rockSmall"> <!-- scrap material -->	
			<property name="Meshfile" value="Items/Crafting/rock_smallPrefab"/>
<property name="Material" value="stone"/>
<property name="HoldType" value="40"/>
<property name="Stacknumber" value="6000"/> <!-- STK resource -->
<property name="RepairAmount" value="300"/>
<property name="Weight" value="5"/>
<property name="EconomicValue" value="5"/>
<property name="EconomicBundleSize" value="50"/>
<property class="Action0"> <!-- AttackAction -->
	<property name="Class" value="ThrowAway"/>
	<property name="Delay" value="1.2"/>
	<property name="Throw_strength_default" value="8"/>
	<property name="Throw_strength_max" value="25"/>
	<property name="Max_strain_time" value="1.5"/>
	<property name="Sound_start" value="swoosh"/>
</property>
<property name="ThrowableDecoy" value="true"/>
<property name="DropScale" value="3"/>
<property name="Group" value="Resources"/>
<property name="CraftingIngredientTime" value="0.5"/>
		</item>
	</append>
</config>

</configs>

Link to comment
Share on other sites

Here it is. This is the version without the stoneTool config.

 

[ATTACH]24705[/ATTACH]

 

Thank you for your patience! It can be frustrating starting out.

 

I didn't see anything in the log. Could you repeat the test, and start a game with it, then repost the log? Also, if you could post your items.xml, that would help too.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...