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

Help Code

Gargioss

New member
Hello, I ask for help for a mod xpath code, example of original code of the simplified "campfire":

part of the original code: <block name="campfire">

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

<property name="Stacknumber" value="1"/>

final results:

<drop event="Destroy" name="campfire" count="1"/>

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

_______________________________________

I have already tried several solutions using the commands:

<remove>, <setattribute> and <append>

but the results lead to error.

It works only <set> on "Stacknumber".

But it works only if I remove the whole code and I hang the new modified code.

it is the only solution ?

Thank you and Happy Holidays to all.

 
This is what you are looking for. Altered from my workbench modlet to change the campfire instead I use this in my full convertion. definitely works. :-)

Code:
<!-- Delete and insert drop event -->
<remove xpath="/blocks/block[@name='campfire']/drop[@event='Destroy']"/>
<insertBefore xpath="/blocks/block[@name='campfire']/drop[@event='Fall']">
   <drop event="Destroy" name="campfire" count="1"/>
</insertBefore>
<!-- resize stack -->
<set xpath="/blocks/block[@name='campfire']/property[@name='Stacknumber']/@value">5</set>
PS: you don't need to use insert before. append will work fine. I just prefer insert before for the accuracy.

 
You can also use the SetAttribute to add the information

Code:
<setattribute xpath="/blocks/block[@name='campfire']/drop" name="name">campfire</setattribute>
<set xpath="/blocks/block[@name='campfire']/property[@name='Stacknumber']/@value">5</set>
<set xpath="/blocks/block[@name='campfire']/drop/@count">1</set>
 
Thanks a lot to both

it works, the second code I had already tried, but certainly I was wrong something.

Thanks again.

PS: for the next post, how do I insert the appropriate table for the code? (sorry for the lack of experience).

 
Use this but remove the spaces in the brackets

[ code]

stuff goes here

[ /code]

becomes

Code:
 stuff goes here
 
Back
Top