Page 38 of 39 FirstFirst ... 2836373839 LastLast
Results 556 to 570 of 571

Thread: XPath Modding Explanation Thread

  1. #556
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,821
    Rep Power
    1
    Quote Originally Posted by JRavens View Post
    Hi guys. I feel really, really dumb. I've tried and tried to grasp XPath and been through the tutorials and looked at other mods and I just cannot get the syntax of it right. Sometimes it works for me, but mostly it doesn't seem to.

    Can someone help me understand how to alter the birdnest block as an example and maybe I can finally get a firm understanding of how some of this is supposed to be properly done? I picked this block because I do want to change it and also I think it's a good example of covering several different cases such as altering, removing and appending lines.

    Here's what I could really use help with:

    1) Does the name of the XML file in a modlet matter? For example Can I use birdnest.xml to implement changes (provided I use proper syntax and nesting) or does it need to be blocks.xml ?
    The files in the Mods/MyMod/Config folder must match the XML it's patching. You wouldn't be able to do birdnest.xml; you'd have to do blocks.xml, if the changes were in the blocks file. If you also need a recipe, you'd have to do a recipes.xml as well.

    Quote Originally Posted by JRavens View Post
    2) Does nesting in the XML file need to contain <config> or <configs>? Is there a necessary syntax for that (it doesn't seem so judging from other modlets I looked at trying to understand). Can I just use <JRavens> or <blahblahblah> so long as it has the requisite closing piece </JRavens>, </blahblahblah> etc.
    The top node doesn't matter what its called, as long as you open and close it. The top node is required because its part of the XML standard, but the game itself doesn't use the value in it.


    Quote Originally Posted by JRavens View Post
    3) Let's say I want to change a blocks material. In this example changing the birdnest from Wood to Grass (because well I think it's a little silly that birdnests have 100 health, clunk when you walk over them and explode into wood chips when destroyed). I tried this with no success:

    Code:
    <set xpath="/blocks/block[@name='cntBirdnest']/property[@name='Material']/@value">Mtallgrass</set>
    In order for the game to pick this up, it'd have to be Config/blocks.xml


    Quote Originally Posted by JRavens View Post
    4) Since I don't want bird nests to be harvested (just destroyed) I want to alter the harvest and destroy lines
    (i.e. I want to player to get a some fibers and maybe some additional feathers when a nest is destroyed)

    So I want to remove these lines:
    Code:
    	<drop event="Harvest" name="resourceCloth" count="1" prob="0.3" tag="allHarvest"/>
    	<drop event="Harvest" name="resourceFeather" count="3" prob="0.35" tag="allHarvest"/>
    	<drop event="Harvest" name="resourceFeather" count="2" prob="0.6" tag="allHarvest"/>
    What's the proper syntax to remove those drop events?
    You would use the remove node.
    Code:
    <remove xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceCloth']" />
    <remove xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceFeather']" />
    <remove xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceFeather']" />
    This may also work, however I don't think it worked in A17:
    Code:
    <remove xpath="/blocks/block[@name='cntBirdnest']/drop" />
    Quote Originally Posted by JRavens View Post
    5) Then say I want to alter this line to drop say half as many max fibers:
    Code:
    	<drop event="Destroy" name="resourceYuccaFibers" count="2,8"/>
    So would this be a correct way to change that line??
    Code:
    <set xpath="/blocks/block[@name='cntBirdnest']/drop[@name='resourceYuccaFibers']/@count">2,4</set>
    Yes, that line looks okay. Again, the changes would have to be done in a file calld blocks.xml


    Quote Originally Posted by JRavens View Post
    6) Finally lets say I want to append (add) in some lines to give a chance to drop some feathers (bird feathers often get stuck in nests and are even used when building them... actually lets go ahead and add back in a tiny chance for cloth or even paper to have been used as material for the nest...).

    Would this code be proper?
    Code:
    <append xpath="/blocks/block[@name='cntBirdnest']" > 
    	<drop event="Destroy" name="resourceFeather" count="0,6" prob="0.8"/>
    	<drop event="Destroy" name="resourceCloth" count="0,1" prob="0.01"/>
    	<drop event="Destroy" name="resourcePaper" count="0,1" prob="0.01"/>
    </append>
    Yes, that'd be the correct xpath. I cannot confirm if the lines will do what you want them to do, since I don't have the files in front of me though.

    Quote Originally Posted by JRavens View Post
    Thanks for any help and / or pointers. I am really struggling with this for some reason. I've never been good with code / regex style strings and such... my brain just doesn't work that way. I much prefer plain text, but I understand the need for xpath and so I would like to understand how to compose it correctly so I cna make my own modlets / mods. Thank you
    I hope this has helped a bit. Good luck, and ask more questions if you need help.

  2. #557
    Refugee
    Join Date
    Aug 2014
    Posts
    3
    Rep Power
    0
    Quote Originally Posted by sphereii View Post
    I hope this has helped a bit. Good luck, and ask more questions if you need help.
    It did! Thank you very much sphereii.

    I think I see now that a lot of my experiments were hit and miss because I wasn't always naming the files properly (bonehead assumption on my part).

    I appreciate the help

  3. #558
    Scavenger
    Join Date
    Jan 2016
    Location
    Brazil
    Posts
    51
    Rep Power
    0
    Quote Originally Posted by sphereii View Post
    Localization Support ( A18 and Beyond )

    As of A18, Localization support from the Mods folder is available in vanilla.

    In the Config folder, create a Localization.txt and a Localization - Quest.txt. This file must match case and spelling of the vanilla entries.

    The localization files files have a heading, like the vanilla version, as a comma delimited line. For mod localization support, you only need to specify the heading that you are adding. For example, if your mod only contains localization for English, you do not need to specify the other language in the heading line.

    If your new localization key matches a vanilla value, or a value from a previously loaded mod, then that value will be updated, with the last mod loaded having the final effect.

    The format of the file is this:

    HEADER
    ENTRY

    Example:

    Code:
    Key,Source,Context,Changes,English
    myKey,UI,Item stat,New,This is my English Key
    Note: If you are only including non-English translation, such as French, and leave the English blank or out, then a user loading the Spanish version will get the localization key. This is because English is the fall back translation. If you specify an English, then the spanish player will see the English localization.
    Actually don't need to put all heading columns. Key and "Language" are enough to work.

    Example:

    English
    Code:
    Key,English
    airConditioner,Air Conditioner
    Spanish
    Code:
    Key,Spanish
    airConditioner,Aire acondicionado
    It works perfectlly with my Portuguese localization.

  4. #559
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,821
    Rep Power
    1
    Quote Originally Posted by SAMUELPV View Post
    Actually don't need to put all heading columns. Key and "Language" are enough to work.

    Example:

    English
    Code:
    Key,English
    airConditioner,Air Conditioner
    Spanish
    Code:
    Key,Spanish
    airConditioner,Aire acondicionado
    It works perfectlly with my Portuguese localization.
    Thank you for the update. That is replacing the existing vanilla localization. I wonder what would happen if you just included Key and language on a completely new item?

    If someone loads your mod, and you only specify Portugesse or Spanish, and they do not have that set, they'll get the raw block or item name from the blocks.xml and items.xml. English is the fall back language to display, if an alternative language isn't specified.

  5. #560
    Scavenger
    Join Date
    Jan 2016
    Location
    Brazil
    Posts
    51
    Rep Power
    0
    Quote Originally Posted by sphereii View Post
    Thank you for the update. That is replacing the existing vanilla localization. I wonder what would happen if you just included Key and language on a completely new item?

    If someone loads your mod, and you only specify Portugesse or Spanish, and they do not have that set, they'll get the raw block or item name from the blocks.xml and items.xml. English is the fall back language to display, if an alternative language isn't specified.
    It works to new items/blocks too.

    Example of my vehicle respawning modlet with spanish language:

    A18.1_2019-11-14_12-07-33.jpg
    Code:
    Key,Spanish
    RespawnCarro,SAMUELPV's Car Respawning

  6. #561
    Scavenger
    Join Date
    Jan 2016
    Location
    Brazil
    Posts
    51
    Rep Power
    0
    This A18 localization support works similar to SDX Tool localization support.

    Example:

    You makes a localization file like this:
    Code:
    Key,English
    myKeyHere,My Text Here
    And SDX Tool pushes to localization file like this:
    Code:
    myKeyHere,,,,My Text Here,,,,,
    Last edited by SAMUELPV; 3 Weeks Ago at 04:17 PM.

  7. #562
    Tracker -Holo-'s Avatar
    Join Date
    May 2016
    Location
    In a nice POI
    Posts
    238
    Rep Power
    0
    Having some weird problems , trying to alter the icons on some of the vanilla items, for example scrapiron, using this line in a modlet items.xml

    <append xpath="/items/item[@name='resourceScrapIron']/property[@name='HoldType']">
    <property name="CustomIcon" value="iron"/>
    </append>

    but ending up with this looks in the items.xml under configdumps,

    <item name="resourceScrapIron">
    <property name="HoldType" value="45">
    <property name="CustomIcon" value="iron"><!--Element appended by: "Holo's fixes"--></property>
    </property>

    what am i doing wrong? tried with append and insertafter but always ending up with the </property> that's not supposed to be there and making the lines unread by the server.

  8. #563
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,821
    Rep Power
    1
    Quote Originally Posted by -Holo- View Post
    Having some weird problems , trying to alter the icons on some of the vanilla items, for example scrapiron, using this line in a modlet items.xml

    <append xpath="/items/item[@name='resourceScrapIron']/property[@name='HoldType']">
    <property name="CustomIcon" value="iron"/>
    </append>

    but ending up with this looks in the items.xml under configdumps,

    <item name="resourceScrapIron">
    <property name="HoldType" value="45">
    <property name="CustomIcon" value="iron"><!--Element appended by: "Holo's fixes"--></property>
    </property>

    what am i doing wrong? tried with append and insertafter but always ending up with the </property> that's not supposed to be there and making the lines unread by the server.
    Your append is too deep. You are telling it to append the CustomIcon lin to HoldType, so it looks like this:

    Code:
    <property name="HoldType" value="45" >
       <property name="CustomIcon" value="iron" />
    </property>
    You want this:


    Code:
    <append xpath="/items/item[@name='resourceScrapIron']">
    <property name="CustomIcon" value="iron"/>
    </append>

  9. #564
    Tracker -Holo-'s Avatar
    Join Date
    May 2016
    Location
    In a nice POI
    Posts
    238
    Rep Power
    0
    Huh. Could have sworn I tried that first o.O It works perfectly now! many many thanks!

  10. #565
    Tracker -Holo-'s Avatar
    Join Date
    May 2016
    Location
    In a nice POI
    Posts
    238
    Rep Power
    0
    Agh. I'll never get the hang of xpath it seems :/ I'm trying to remove items from the progression, so we -must- find the schematic,
    trying to remove the whole line with
    <remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group[@tags='chemistryStation']" />

    but the game won't allow that and I'm not sure how to remove things from progression and can't find any examples from other mods
    Last edited by -Holo-; 1 Week Ago at 02:31 PM. Reason: forgot /progresson at the start of the line

  11. #566
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,821
    Rep Power
    1
    Quote Originally Posted by -Holo- View Post
    Agh. I'll never get the hang of xpath it seems :/ I'm trying to remove items from the progression, so we -must- find the schematic,
    trying to remove the whole line with
    <remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group[@tags='chemistryStation']" />

    but the game won't allow that and I'm not sure how to remove things from progression and can't find any examples from other mods
    You are close. The chemistryline is part of the passive_effect line, not the effectgroup itself. Once you target the passive_effect line, you can add the name attribute as an additional condition, or continue just to target the @tags='chemistryStation'.
    Code:
    <remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group/passive_effect[@name='RecipeTagUnlocked' and @tags='chemistryStation']" />
    
    <remove xpath="/progression/perks/perk[@name='perkYeahScience']/effect_group/passive_effect[@tags='chemistryStation']" />

  12. #567
    Refugee
    Join Date
    Dec 2019
    Posts
    3
    Rep Power
    0
    Hello,

    I'm having trouble with a "simple-ish" modlet I'm trying to make. I'm basically trying to change the % value of all zombies in game from 1 to .5 or 0.1 or whatever (aka, so they have less life). I want to do it through the % values so the game balance stays intact (somewhat).

    The game loads the mod properly at the start of the game, displays the version, but it doesn't do anything. The zombies have the same health value as they had before.

    This is my modlet code for the entityclasses.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <entityclasses>
    
    <set xpath="/entity_classes/entity_class[starts-with(@name,'zombie')]/effect_group[@name='Base Effects']/passive_effect[@name='HealthMax'][@operation='perc_set'][@value='1']/@value">.1</set>
    
    </entityclasses>
    What did I mess up?

    p.s. sphereii, bless your soul for helping us

  13. #568
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,821
    Rep Power
    1
    Quote Originally Posted by devon752 View Post
    Hello,

    I'm having trouble with a "simple-ish" modlet I'm trying to make. I'm basically trying to change the % value of all zombies in game from 1 to .5 or 0.1 or whatever (aka, so they have less life). I want to do it through the % values so the game balance stays intact (somewhat).

    The game loads the mod properly at the start of the game, displays the version, but it doesn't do anything. The zombies have the same health value as they had before.

    This is my modlet code for the entityclasses.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <entityclasses>
    
    <set xpath="/entity_classes/entity_class[starts-with(@name,'zombie')]/effect_group[@name='Base Effects']/passive_effect[@name='HealthMax'][@operation='perc_set'][@value='1']/@value">.1</set>
    
    </entityclasses>
    What did I mess up?

    p.s. sphereii, bless your soul for helping us
    It seems to be a valid xpath. Have you checked your exported configs, under your SaveGame folder to see if it applied the changes you expect? It could be that what you are changing isn't the final determination on what the health of a zombie has.

  14. #569
    Refugee
    Join Date
    Dec 2019
    Posts
    3
    Rep Power
    0
    Quote Originally Posted by sphereii View Post
    It seems to be a valid xpath. Have you checked your exported configs, under your SaveGame folder to see if it applied the changes you expect? It could be that what you are changing isn't the final determination on what the health of a zombie has.
    I presume it's the thing under %appdata% so I went there, specifically under "C:\Users\PCuser\AppData\Roaming\7DaysToDie\Saves\ Navezgane\myworld\ConfigsDump\entityclasses.xml"

    And yes, as you said, it didn't apply the changes there.
    Another thing that I forgot to mention is that I tried changing these values manually and when I changed them manually with notepad++ (all 84 lines that matched that line and the value "1") it applied the HP change as intended. Since that worked I went and tried to make a modlet that would do the same but unfortunately it didn't work :/

    The only other mod I'm using is the SMX hud overhaul but I doubt that would be causing any conflicts.
    Wat do? Am I perhaps missing something with my mod structure? I attached an image below showing my whole folder structure for the mod.


  15. #570
    Refugee
    Join Date
    Dec 2019
    Posts
    3
    Rep Power
    0
    Nvm! I fixed it!

    I deleted the Item Icons folder since I wasn't using it ( I checked it was for A17 and before) and I added the mod.xml and filled out the required data. Works like a charm. Thanks for the help! <3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •