Jump to content

XPath Modding Explanation Thread


sphereii

Recommended Posts

 

i wish i was right. I reviewed the fl and all are saved as .xml. and still not working. I can see where boot says it is reading them. but when you log into the game it still gives the vanilla starting loot. I have even tried deleting the blocks and loot files and replacing the item with a vanilla one, and it still ignores the swapped loot.

 

 

I am having the same problem with several other peoples mods, where the vanilla files are simply not being overwritten at bootup, even though the boot files says that it read the modlet.

 

Do you have a zip file of one of these mods along with a log file?

Link to comment
Share on other sites

so i figured out the real issue. even if i open up a .xml file. whenever i hit save, notepadd++ converts it to a .txt

 

if i try to resave as extensivemarkup (.xml, etc) it ells me it cant as the file is already open. If create new file and try to save it, same issue.if i delete the hardcopy and try to save either of the two previous ways, it ways it is still open. ifi create brand new file and select save as extensive markup (as pure .xml is nto available) it still sets it as .txt.

 

I have tried to update notepadd++, wipe cookies and cache, reboot my computer, start with bran new files, and still have it only saving everything as .txt.

 

I thank you for your help. I must find anotherfree program for writing code as clearly my version of notepad++ is broken.

 

 

Link to comment
Share on other sites

  • 4 weeks later...
56 minutes ago, voxlltv said:

I had bookmarked this forum post. I use it all the time.

However, right now, it seems the CODE blocks are broken, so I can't really read the original posts.

Give it a day or two, and it should sort itself out.

Link to comment
Share on other sites

Hello...returning player here (so please excuse the ignorance :) )

I'm trying to add some more functions to "Action1" for the drinkJarEmpty using <append> (eg. drawing water from showerheads.)

i've read all of the examples on page 1 and had a couple of tries but i haven't had any luck yet...is it something straightforward or am i asking too much at the current point in time?

Thanks in advance :)

 

Edited by DW420 (see edit history)
Link to comment
Share on other sites

On 4/30/2020 at 10:02 AM, DW420 said:

Hello...returning player here (so please excuse the ignorance :) )

I'm trying to add some more functions to "Action1" for the drinkJarEmpty using <append> (eg. drawing water from showerheads.)

i've read all of the examples on page 1 and had a couple of tries but i haven't had any luck yet...is it something straightforward or am i asking too much at the current point in time?

Thanks in advance :)

 

Say you wanted to add something inside the Action1 of an item called ThisItem, you would do it like this:

In items.xml of your mod:

<configs>
  <append xpath="/items/item[@name='ThisItem']/property[@class='Action1']">
  	<!-- Your additional code goes here -->
  </append>
</configs>

 

Edited by mr.devolver (see edit history)
Link to comment
Share on other sites

4 hours ago, mr.devolver said:

Say you wanted to add something inside the Action1 of an item called ThisItem, you would do it like this:

In items.xml of your mod:


<configs>
  <append xpath="/items/item[@name='ThisItem']/property[@class='Action1']">
  	<!-- Your additional code goes here -->
  </append>
</configs>

 

Thnx for the reply.

i was trying syntax similar to:

<append xpath="/items/item/property[@class='Action1']/property[@name='drinkJarEmpty' or @name='bucketEmpty']/@name='Focused_blockname_6' value="faucet02"></append>



with no success....guess I'm going to simplify how i try to express what i want done...

PS. Would i be right to assume that if i wanted to add an alternative action 1 i would have to write it down as

<configs>
  <append xpath="/items/item[@name='ThisItem']">
      <!-- Code similar to this goes here -->
      <property class="Action1"> <!-- UseAction -->
        <property name="Class" value="ExchangeItem"/>
        <property name="Delay" value="1.0"/>
        <property name="Change_item_to" value="NAME-ResultingItem"/>
        <property name="Do_block_action" value="deplete1"/>     <---------------------------this line is for natural water blocks only ?
        <property name="Focused_blockname_1" value="NAME-TargetBlock"/>
        <property name="Sound_start" value="bucketfill_water"/>
    </property>    
  </append>
</configs>


 
--The optimal result for what i'm looking to achieve (atm) is having the ability to scavenge different items from different sources whilst introducing as few custom items as possible...eg being able to collect with EmptyJar dirty water from shower heads, petrol from cars/gas pumps, wine from wine barrels..

I figured that attempting a forge-like bottling plant...would be good practice and (perhaps ?) the end product can fill a gap in terms of user modded content for 18.4
Link to comment
Share on other sites

Your code for adding Action1 on item with name ThisItem is correct, but please note that doing it exactly as you wrote it really assumes that the item called ThisItem does not have Action1 in its code yet.

 

If it already has Action1 in its code and you want to modify it somehow, you have the following options:

1) change individual parts of the existing code

2) remove the whole Action1 property and then write a new one that would take place of the original

3) add to the existing code

 

Code for all of these options would be different and generally the less amount of changes means better compatibility with other mods that may depend on the vanilla code.

 

Action0 and Action1 actually represent left and right mouse button actions, so the game would most likely throw you an error if you tried to add a "an alternative action 1" leaving the code with two Action1 properties.

 

Assuming that all you really want is just to add some new code inside an existing Action1 property of drinkJarEmpty item, your code in items.xml of your mod would look like this:

  <append xpath="/items/item[@name='drinkJarEmpty']/property[@class='Action1']">
  	<!-- Any code written here will go inside Action1 property of drinkJarEmpty item -->
  </append>

Again, this is for injecting a new code inside the existing Action1 property of drinkJarEmpty. If you wanted to edit the existing code there, not to add new one, you would have to do it differently. What would the code look like in that case highly depends on what exactly you would want to change there.

Edited by mr.devolver (see edit history)
Link to comment
Share on other sites

7 hours ago, mr.devolver said:

Say you wanted to add something inside the Action1 of an item called ThisItem, you would do it like this:

In items.xml of your mod:


<configs>
  <append xpath="/items/item[@name='ThisItem']/property[@class='Action1']">
  	<!-- Your additional code goes here -->
  </append>
</configs>

 

Thanks for the reply :) Please allow me to be a bit more specific  in order to (hopefully) assist you in helping me.

I would like to add different results depending on the source where the liquid was sourced from...but i cant find any vanilla item that actually does something similar...so i'm throwing rocks in the dark, hoping to hear the right kind of thunk sort of speak...

So far...The following code adds dirty water collection from sinks etc..i'll call it codeA from now on for short.

    <append xpath="/items/item[@name='drinkJarEmpty']/property[@class='Action1']">
        <property name="Focused_blockname_6" value="faucet02"/>
        <property name="Focused_blockname_7" value="faucet04"/>
        <property name="Focused_blockname_8" value="faucetBrass02"/>
        <property name="Focused_blockname_9" value="faucetBrass04"/>
        <property name="Focused_blockname_10" value="cntToilet01"/>
        <property name="Focused_blockname_11" value="cntToilet02"/>
        <property name="Focused_blockname_12" value="cntToilet03"/>
        <property name="Focused_blockname_13" value="cntCabinetOldSink"/> 
        <property name="Focused_blockname_14" value="cntGraniteSink"/>
        <property name="Focused_blockname_15" value="utilitySink"/>
        <property name="Focused_blockname_16" value="wallHungSink"/>
        <property name="Focused_blockname_17" value="showerHead"/>
        <property name="Focused_blockname_18" value="fountain"/>
    </append>


The issues arise once i try to add another result/source:

- Appending an extra 'Action1' block of code as a new entry further down the config throws an error. (just like you said) 

- Appending the following block of code (codeB) as a new entry further down the config forces all sources appended from codeA to now provide clean water.

    <append xpath="/items/item[@name='drinkJarEmpty']/property[@class='Action1']">
        <property name="Class" value="ExchangeItem"/>
        <property name="Delay" value="1.0"/>
        <property name="Change_item_to" value="drinkJarBoiledWater"/>
<---blockname_1 or blockname_19 makes no difference to the result-->
        <property name="Focused_blockname_1" value="cntWaterCoolerFull"/>
        <property name="Sound_start" value="bucketfill_water"/>
    </append>

 

- Appending both CodeA and Codeb as a single entry also forces all sources appended to provide clean water.

    <append xpath="/items/item[@name='drinkJarEmpty']/property[@class='Action1']">
        codeA
        codeB
    </append>

This was also the case 4 years ago...you couldn't have more than 1 type of liquid collected via glass jar.

Is that possible atm?
If not , would a tool that uses glass jars as fuel/ammo be (theoretically) able to do this...given what one can or can't do at this point of time?
Thanks in advance :)
 

 

Edited by DW420
half the post went missing... (see edit history)
Link to comment
Share on other sites

2 hours ago, DW420 said:

Thanks for the reply :) Please allow me to be a bit more specific  in order to (hopefully) assist you in helping me.

I would like to add different results depending on the source where the liquid was sourced from...but i cant find any vanilla item that actually does something similar...so i'm throwing rocks in the dark, hoping to hear the right kind of thunk sort of speak...

So far...The following code adds dirty water collection from sinks etc..i'll call it codeA from now on for short.


    <append xpath="/items/item[@name='drinkJarEmpty']/property[@class='Action1']">
        <property name="Focused_blockname_6" value="faucet02"/>
        <property name="Focused_blockname_7" value="faucet04"/>
        <property name="Focused_blockname_8" value="faucetBrass02"/>
        <property name="Focused_blockname_9" value="faucetBrass04"/>
        <property name="Focused_blockname_10" value="cntToilet01"/>
        <property name="Focused_blockname_11" value="cntToilet02"/>
        <property name="Focused_blockname_12" value="cntToilet03"/>
        <property name="Focused_blockname_13" value="cntCabinetOldSink"/> 
        <property name="Focused_blockname_14" value="cntGraniteSink"/>
        <property name="Focused_blockname_15" value="utilitySink"/>
        <property name="Focused_blockname_16" value="wallHungSink"/>
        <property name="Focused_blockname_17" value="showerHead"/>
        <property name="Focused_blockname_18" value="fountain"/>
    </append>


The issues arise once i try to add another result/source:

- Appending an extra 'Action1' block of code as a new entry further down the config throws an error. (just like you said) 

- Appending the following block of code (codeB) as a new entry further down the config forces all sources appended from codeA to now provide clean water.


    <append xpath="/items/item[@name='drinkJarEmpty']/property[@class='Action1']">
        <property name="Class" value="ExchangeItem"/>
        <property name="Delay" value="1.0"/>
        <property name="Change_item_to" value="drinkJarBoiledWater"/>
<---blockname_1 or blockname_19 makes no difference to the result-->
        <property name="Focused_blockname_1" value="cntWaterCoolerFull"/>
        <property name="Sound_start" value="bucketfill_water"/>
    </append>

 

- Appending both CodeA and Codeb as a single entry also forces all sources appended to provide clean water.


    <append xpath="/items/item[@name='drinkJarEmpty']/property[@class='Action1']">
        codeA
        codeB
    </append>

This was also the case 4 years ago...you couldn't have more than 1 type of liquid collected via glass jar.

Is that possible atm?
If not , would a tool that uses glass jars as fuel/ammo be (theoretically) able to do this...given what one can or can't do at this point of time?
Thanks in advance :)
 

 

Please note that <append> command is really for adding new things within the scope of the last node inside the xpath. If you would rather want to change the existing parts of the code inside that node, you could construct a <set> command to target specific lines of code to change their values, or <insertAfter> / <insertBefore> to add lines after or before the specified xpath. I believe your codeB is a good example where you should be using something different than append as drinkJarEmpty already contains some of those lines you're adding and just like in case of Action1 duplicate, duplication of other lines of code may be undesirable as well.

 

As for the solution for your actual problem, right now I can't think of anything that I know would surely work, but that doesn't mean there's no solution for it. Some modders are quite resourceful and could probably give you a solution for this with no problem. You could try cvars, buffs, custom effect groups with predefined requirements or combinations of them. I may be wrong, but perhaps it could be done by setting up custom effect group that would give different results based on various different requirements. If everything else fails, you could get this done through DMT (Successor of SDX), but of course that's a whole new level of modding.

Link to comment
Share on other sites

Hmm....perhaps i should go the roundabout way for now...and look to create forge-like versions of the blocks i want to use as sources then use jars as the ingredient and polymer as the fuel (think of it as the cost for making sealed bottle caps)...then get them in the game as "extra options" so that they spawn alongside the vanilla blocks for POIs.

(that has its issues/limitations as well, as you wont be able to loot them...but the player's inventory wont be cluttered with so many different jars .)

I wouldn't know where to start with DMT etc  :) hopefully someone who knows what they are doing will sort it out eventually :) 

Link to comment
Share on other sites

  • 2 weeks later...

I don’t know if anyone will see this but I’ve been trying so so hard to write up a modlet that will make it so hostile animals will still spawn with enemy spawning turned off, I know I’m looking at entity classes and the hostileanimalstemplate but when I load in to game I get the error ‘element does not contain attribute’ 

Link to comment
Share on other sites

On 5/15/2020 at 1:25 AM, yepitschristinaa said:

I don’t know if anyone will see this but I’ve been trying so so hard to write up a modlet that will make it so hostile animals will still spawn with enemy spawning turned off, I know I’m looking at entity classes and the hostileanimalstemplate but when I load in to game I get the error ‘element does not contain attribute’ 

Instead of turning enemy spawning off completely, make a mod that will remove zombie groups from spawning and only leave animals, assuming that is what you're after.

Link to comment
Share on other sites

  • 1 month later...

Guys, I need help! Why do I get an error (screenshot under the spoiler) when connecting friends to me without the modlet installed (and with it, too), which is why they can't connect, freezing on getting server configurations? Although I can easily connect to them with the modlet installed.

 

Spoiler

100164930.83500001_image.png

 

output_log__2020-07-05__02-35-06.txt

Edited by fenymak (see edit history)
Link to comment
Share on other sites

17 hours ago, fenymak said:

Guys, I need help! Why do I get an error (screenshot under the spoiler) when connecting friends to me without the modlet installed (and with it, too), which is why they can't connect, freezing on getting server configurations? Although I can easily connect to them with the modlet installed.

 

  Hide contents

100164930.83500001_image.png

 

output_log__2020-07-05__02-35-06.txt 35.77 kB · 0 downloads

What does your localization file look like on the server? The server log might give a hint on which localization is causing the issue.

Link to comment
Share on other sites

2 hours ago, sphereii said:

What does your localization file look like on the server? The server log might give a hint on which localization is causing the issue.

This topic contains a modlet with my alternative localization. The server is local - I create a game, and my friends just join me. I attached the log. Or do you need another one? If so where can I get it?

Link to comment
Share on other sites

  • 2 weeks later...

Quick question:

 

I am trying to tweak the Experience Gain multiplier for Nerd Glasses.  I can't seem to get the xpath to work.  I've tried these to no avail:

 

<set xpath="/items/item[@name='apparelNerdGlasses']/passive_effect[@name='PlayerExpGain']/@value">0.25</set>

<set xpath="/items/item[@name='apparelNerdGlasses']/passive_effect[@name='PlayerExpGain']/operation[@name='perc_add']/@value">0.25</set>

 

Any suggestions/solutions?  Any help would be appreciated!

 

DaemonGeek

Edited by DaemonGeek (see edit history)
Link to comment
Share on other sites

On 7/25/2020 at 4:46 PM, DaemonGeek said:

Quick question:

 

I am trying to tweak the Experience Gain multiplier for Nerd Glasses.  I can't seem to get the xpath to work.  I've tried these to no avail:

 

<set xpath="/items/item[@name='apparelNerdGlasses']/passive_effect[@name='PlayerExpGain']/@value">0.25</set>

<set xpath="/items/item[@name='apparelNerdGlasses']/passive_effect[@name='PlayerExpGain']/operation[@name='perc_add']/@value">0.25</set>

 

Any suggestions/solutions?  Any help would be appreciated!

 

DaemonGeek

I think you are missing the <effect_group> node, which contains the passive_effect

 

<set xpath="/items/item[@name='apparelNerdGlasses']/effect_group/passive_effect[@name='PlayerExpGain']/@value">0.25</set>

Link to comment
Share on other sites

On 7/27/2020 at 5:25 AM, sphereii said:

I think you are missing the <effect_group> node, which contains the passive_effect

 

<set xpath="/items/item[@name='apparelNerdGlasses']/effect_group/passive_effect[@name='PlayerExpGain']/@value">0.25</set>

That did the trick, thanks!

 

I thought I had tried every permutation but I think I included the operation="perc_add" in the attempt using effect_group. 

Link to comment
Share on other sites

  • 3 weeks later...

ok  - people who know more than I do - which is 99% of you

I have been fighting with trying to vary zombie xp without editing every  single zombie - tried this

<set xpath="/entity_classes/entity_class[contains(@name, 'zombie')]/property[contains(@name, 'ExperienceGain')]/@value">*.25</set>  

 

set all  occurrences of experiencegain on a zombie entity to  25% of what it was .

 

which "logically" should work as far as I understand BUT it doesnt  

 

please put me out of my misery before i smack my head through a wall  :)

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
×
×
  • Create New...