• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Modify value of a drop event

Frekton

Refugee
Having a hard time figuring the correct syntax to access the "drop event" so that i can change the value of count.

Code:
<drop event="Harvest" name="resourceIronFragment" count="49" tag="oreWoodHarvest"/>
 
Hopefully this helps using xpath append its the easiest way to understand xpath syntax

The easiest way to make a value change is to first copy the whole block name in this case that way you have all the information in front of you for this block name in blocks.xml terrOreIron

<block name="terrOreIron">


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



<property name="MaxDamage" value="1000" />



<property name="Shape" value="Terrain"/>



<property name="Mesh" value="terrain"/>



<property name="Texture" value="33"/>



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



<drop event="Harvest" name="resourceIronFragment" count="49" tag="oreWoodHarvest"/>



<drop event="Harvest" name="resourceRockSmall" count="16" tag="oreWoodHarvest"/>



<drop event="Destroy" count="0"/>



<drop event="Fall" name="resourceIronFragment" count="39" prob="0.5" stick_chance="0"/>



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



<property name="FilterTags" value="fterrain"/>



<property name="SortOrder1" value="d0l0"/>



<property name="SortOrder2" value="0050"/>



<property name="DisplayType" value="blockTerrain" />



</block>


To change (append) a new value we can specify the blocks xml as root (beginning of path)

Code:
<append xpath="/blocks" >
and then the block name

Code:
<append xpath="/blocks/block[@name='terrOreIron']">
Then the part you need to alter can be added by referencing the code above in this case you want to change the line

<drop event="Harvest" name="resourceIronFragment" count="49" tag="oreWoodHarvest"/>

Final code then for a simple append would be

Code:
<configs>
<append xpath="/blocks/block[@name='terrOreIron']">
<drop event="Harvest" name="resourceIronFragment" count="1000" tag="oreWoodHarvest"/>
</append>
</configs>
There is a tutorial on xpath by Sphereii here https://7daystodie.com/forums/showthread.php?93816-XPath-Modding-Explanation-Thread

and a video tutorial here https://7daystodie.com/forums/showthread.php?99518-Video-Tutorial-XPath-Modding-in-A17-for-Beginners

 
Last edited by a moderator:
TY! I was trying to change the 'count' value by using this but I could not get it to work. Could not get it to recognize the "drop" property.

Code:
<set xpath="/blocks/block[@name='terrOreIron']
 
Unfortunately this does not work either. It is giving me NRE error.

Code:
<append xpath="/blocks">
<block name="terrOreIron">
<drop event="Harvest" name="resourceIronFragment" count="1000" tag="oreWoodHarvest"/>
</append>
It is looking for the </block> before </append> to close the block. But that tells the system to add a block where i want to change a value to a property in an existing block, should i not use <set xpath="/blocks/block[@name=terrOreIron] ?

 
Thats the beaty of xpath there are different ways of doing things you can use 'set' but its much harder to get the syntax right.

for example my vehicle code to set camera positions to simulate a first person mode like you get in Debug mode

Code:
<set xpath="/vehicles/vehicle[@name='vehicleBicycle']/property[@name='cameraDistance' and @value='3, 4.5']/@value">-0.35, -1.55</set>
<set xpath="/vehicles/vehicle[@name='vehicleBicycle']/property[@name='cameraTurnRate' and @value='.2, .35']/@value">0.09, 0.25</set>
 
Yeah that's the problem I'm having, I can't figure out the syntax. I guess I'll keep trying
In order to change values using append sometimes you have to first remove the block and then append it back in to change values , with set its like you are experiencing very difficult to get syntax right first time ..

I spotted my own mistake in the append code i gave you and have altered the original post so as not to mislead anyone

Code:
<configs>
<append xpath="/blocks/block[@name='terrOreIron']">
<drop event="Harvest" name="resourceIronFragment" count="1000" tag="oreWoodHarvest"/>
</append>
</configs>
 
Last edited by a moderator:
I ran the game up and used exportcurrentconfigs in the F1 console to see if this worked and it does in the blocks.xml there is this message about the modlet applying the change to the element.

<drop event="Harvest" name="resourceIronFragment" count="1000" tag="oreWoodHarvest"><!--Element appended by: "Zorecount"--></drop>

 
This is untested but should work, assuming you are trying to change the Harvest amount of iron from an iron node, its set at 100

Code:
<set xpath="/blocks/block[@name='terrOreIron']/drop[@event='Harvest'][@name='resourceIronFragment']/@count">100</set>
 
I ran the game up and used exportcurrentconfigs in the F1 console to see if this worked and it does in the blocks.xml there is this message about the modlet applying the change to the element.
<drop event="Harvest" name="resourceIronFragment" count="1000" tag="oreWoodHarvest"><!--Element appended by: "Zorecount"--></drop>
This did add a new line to the block i was trying to edit, but in reality if i wanted to lower the count it wouldn't work. Thank you for trying to help.

- - - Updated - - -

This is untested but should work, assuming you are trying to change the Harvest amount of iron from an iron node, its set at 100

Code:
<set xpath="/blocks/block[@name='terrOreIron']/drop[@event='Harvest'][@name='resourceIronFragment']/@count">100</set>
Lol that's that the trick , I hate it when it's so simple. I was doing

Code:
@value">10/set>
instead of

Code:
/@count">10</set
 
This is untested but should work, assuming you are trying to change the Harvest amount of iron from an iron node, its set at 100

Code:
<set xpath="/blocks/block[@name='terrOreIron']/drop[@event='Harvest'][@name='resourceIronFragment']/@count">100</set>
Does work DukeW74.

 
Back
Top