Page 2 of 39 FirstFirst 123412 ... LastLast
Results 16 to 30 of 582

Thread: XPath Modding Explanation Thread

  1. #16
    Colony Founder Prisma501's Avatar
    Join Date
    Sep 2016
    Location
    NL - Tilburg
    Posts
    1,307
    Rep Power
    1
    Excellent info.

    Cheers

    -edit- hope you dont get any PM's asking if and where you got A17

  2. #17
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,829
    Rep Power
    1
    Quote Originally Posted by Prisma501 View Post
    Excellent info.

    Cheers

    -edit- hope you dont get any PM's asking if and where you got A17
    If I had access to it, I doubt I'd be here

    I'd be in-game

  3. #18
    Colony Founder Prisma501's Avatar
    Join Date
    Sep 2016
    Location
    NL - Tilburg
    Posts
    1,307
    Rep Power
    1
    Quote Originally Posted by sphereii View Post
    If I had access to it, I doubt I'd be here

    I'd be in-game
    Yeh lmao! My thoughts. There are others though who have a strange way of thinking

    Cheers

  4. #19
    Colony Founder Kubikus's Avatar
    Join Date
    Apr 2015
    Posts
    1,418
    Rep Power
    1
    Good tut.

    I have a question. Here is a set of commands I've converted to xpath. Now, if the property "MaxDamage" is not in the xml for the block with the name @name='so-and-so', will it automatically be added or nah? If nah, is there a function that will only add the property if it's not there already? And if there is no way to automatically add it only if it's not there, what if I added the property to a block that already has it, would my addition overwrite the existing property or add it a 2nd time (which should be illegal)?

    Is there, in other words, a method that will either change a property, or, if the property does not even exist, add it, so I do not have to know if it's there or not?

  5. #20
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,829
    Rep Power
    1
    Quote Originally Posted by Kubikus View Post
    Good tut.

    I have a question. Here is a set of commands I've converted to xpath. Now, if the property "MaxDamage" is not in the xml for the block with the name @name='so-and-so', will it automatically be added or nah? If nah, is there a function that will only add the property if it's not there already? And if there is no way to automatically add it only if it's not there, what if I added the property to a block that already has it, would my addition overwrite the existing property or add it a 2nd time (which should be illegal)?

    Is there, in other words, a method that will either change a property, or, if the property does not even exist, add it, so I do not have to know if it's there or not?
    I don't believe SDX had something like that. It'd be worth trying it out when we get the experimental release and see what actually works and doesn't.

  6. #21
    Colony Founder Prisma501's Avatar
    Join Date
    Sep 2016
    Location
    NL - Tilburg
    Posts
    1,307
    Rep Power
    1
    Quote Originally Posted by Kubikus View Post
    Good tut.

    I have a question. Here is a set of commands I've converted to xpath. Now, if the property "MaxDamage" is not in the xml for the block with the name @name='so-and-so', will it automatically be added or nah? If nah, is there a function that will only add the property if it's not there already? And if there is no way to automatically add it only if it's not there, what if I added the property to a block that already has it, would my addition overwrite the existing property or add it a 2nd time (which should be illegal)?

    Is there, in other words, a method that will either change a property, or, if the property does not even exist, add it, so I do not have to know if it's there or not?
    Can be done by using operators. TheElement[not(@attribute= 'whatevervalue')]

    This will skip (or use depending on what you want) elements that do not contain the attribute or contain it but dont have expected value.

    Cheers

    -edit- all depending on xpath functions implemented by TFP of course.
    Last edited by Prisma501; 11-15-2018 at 11:18 AM.

  7. #22
    Colony Founder Kubikus's Avatar
    Join Date
    Apr 2015
    Posts
    1,418
    Rep Power
    1
    Quote Originally Posted by Prisma501 View Post
    Can be done by using operators. TheElement[not(@attribute= 'whatevervalue')]

    This will skip (or use depending on what you want) elements that do not contain the attribute or contain it but dont have expected value.

    Cheers

    -edit- all depending on xpath functions implemented by TFP of course.
    I don't want it to skip if the property is already there. If it's already there, the value should be changed. If the property is not already there, it should be added with the value. For example:

    Code:
    <block id="150" name="woodFrameWedge">
    	<property name="Extends" value="woodFrameMaster"/>
    	<property name="CreativeMode" value="Player"/>
    	<property name="Shape" value="New"/>
    	<property name="Model" value="wedge60"/> <property name="Place" value="TowardsPlacerInverted"/>
    	<property name="CanPickup" value="true"/>
    	<property class="UpgradeBlock"> <property name="ToBlock" value="woodWedge"/>	</property>
    </block>
    This one has no "MaxDamage" property. It should be added with the value I want like so:

    Code:
    <block id="150" name="woodFrameWedge">
    	<property name="MaxDamage" value="75"/>
    	<property name="Extends" value="woodFrameMaster"/>
    	<property name="CreativeMode" value="Player"/>
    	<property name="Shape" value="New"/>
    	<property name="Model" value="wedge60"/> <property name="Place" value="TowardsPlacerInverted"/>
    	<property name="CanPickup" value="true"/>
    	<property class="UpgradeBlock"> <property name="ToBlock" value="woodWedge"/>	</property>
    </block>
    This one already has the property (it does not actually, but let's say):

    Code:
    <block id="830" name="woodHalf">
    	<property name="MaxDamage" value="100"/>
    	<property name="Extends" value="woodMaster" />
    	<property name="Shape" value="New" />
    	<property name="Model" value="cube_half" />
    	<property class="UpgradeBlock"> <property name="ToBlock" value="rWoodHalf" /> </property>
    	<property name="DowngradeBlock" value="solidWoodFrameHalf" />
    </block>
    And in this case, I want the command to change the value, like so:

    Code:
    <block id="830" name="woodHalf">
    	<property name="MaxDamage" value="50"/>
    	<property name="Extends" value="woodMaster" />
    	<property name="Shape" value="New" />
    	<property name="Model" value="cube_half" />
    	<property class="UpgradeBlock"> <property name="ToBlock" value="rWoodHalf" /> </property>
    	<property name="DowngradeBlock" value="solidWoodFrameHalf" />
    </block>
    And what I don't want is something like this:

    Code:
    <block id="830" name="woodHalf">
    	<property name="MaxDamage" value="50"/>
    	<property name="MaxDamage" value="100"/>
    	<property name="Extends" value="woodMaster" />
    	<property name="Shape" value="New" />
    	<property name="Model" value="cube_half" />
    	<property class="UpgradeBlock"> <property name="ToBlock" value="rWoodHalf" /> </property>
    	<property name="DowngradeBlock" value="solidWoodFrameHalf" />
    </block>
    Same property twice.

    So I don't want to have to check wether the property exists or not.

  8. #23
    Colony Founder Prisma501's Avatar
    Join Date
    Sep 2016
    Location
    NL - Tilburg
    Posts
    1,307
    Rep Power
    1
    Quote Originally Posted by Kubikus View Post
    I don't want it to skip if the property is already there. If it's already there, the value should be changed. If the property is not already there, it should be added with the value. For example:

    Code:
    <block id="150" name="woodFrameWedge">
    	<property name="Extends" value="woodFrameMaster"/>
    	<property name="CreativeMode" value="Player"/>
    	<property name="Shape" value="New"/>
    	<property name="Model" value="wedge60"/> <property name="Place" value="TowardsPlacerInverted"/>
    	<property name="CanPickup" value="true"/>
    	<property class="UpgradeBlock"> <property name="ToBlock" value="woodWedge"/>	</property>
    </block>
    This one has no "MaxDamage" property. It should be added with the value I want like so:

    Code:
    <block id="150" name="woodFrameWedge">
    	<property name="MaxDamage" value="75"/>
    	<property name="Extends" value="woodFrameMaster"/>
    	<property name="CreativeMode" value="Player"/>
    	<property name="Shape" value="New"/>
    	<property name="Model" value="wedge60"/> <property name="Place" value="TowardsPlacerInverted"/>
    	<property name="CanPickup" value="true"/>
    	<property class="UpgradeBlock"> <property name="ToBlock" value="woodWedge"/>	</property>
    </block>
    This one already has the property (it does not actually, but let's say):

    Code:
    <block id="830" name="woodHalf">
    	<property name="MaxDamage" value="100"/>
    	<property name="Extends" value="woodMaster" />
    	<property name="Shape" value="New" />
    	<property name="Model" value="cube_half" />
    	<property class="UpgradeBlock"> <property name="ToBlock" value="rWoodHalf" /> </property>
    	<property name="DowngradeBlock" value="solidWoodFrameHalf" />
    </block>
    And in this case, I want the command to change the value, like so:

    Code:
    <block id="830" name="woodHalf">
    	<property name="MaxDamage" value="50"/>
    	<property name="Extends" value="woodMaster" />
    	<property name="Shape" value="New" />
    	<property name="Model" value="cube_half" />
    	<property class="UpgradeBlock"> <property name="ToBlock" value="rWoodHalf" /> </property>
    	<property name="DowngradeBlock" value="solidWoodFrameHalf" />
    </block>
    And what I don't want is something like this:

    Code:
    <block id="830" name="woodHalf">
    	<property name="MaxDamage" value="50"/>
    	<property name="MaxDamage" value="100"/>
    	<property name="Extends" value="woodMaster" />
    	<property name="Shape" value="New" />
    	<property name="Model" value="cube_half" />
    	<property class="UpgradeBlock"> <property name="ToBlock" value="rWoodHalf" /> </property>
    	<property name="DowngradeBlock" value="solidWoodFrameHalf" />
    </block>
    Same property twice.

    So I don't want to have to check wether the property exists or not.
    Yes and thats possible in xpath using operators, queries and stringlen checks, but as said, the pimps implementation is what has to support it. Depending if they implement that sort of advanced usage, we will be able to use. We will have to wait and see.

    Cheers

  9. #24
    Colony Founder Kubikus's Avatar
    Join Date
    Apr 2015
    Posts
    1,418
    Rep Power
    1
    Quote Originally Posted by Prisma501 View Post
    Yes and thats possible in xpath using operators, queries and stringlen checks, but as said, the pimps implementation is what has to support it. Depending if they implement that sort of advanced usage, we will be able to use. We will have to wait and see.

    Cheers
    If you know how exactly the command would have to look for that, might you provide an example..? I (briefly) looked into other tutorials and could not find what I'm looking for.

    If the game won't support such stuff, it should be a good idea to find something that does, I find an option like this fairly essential. How does it work anyway, what turns the commands into actual xml-code? I'm not much of a programmer, so I don't know what's it called, a compiler? Interpreter? If the game can't do, are there stand alone programs available or easy to make?


    Edit: I have, btw, understood that whatever the game uses will not even put out any actualy xml-files anymore. But I assume there are such programs, so... No confusion plz.
    Last edited by Kubikus; 11-15-2018 at 12:03 PM.

  10. #25
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,829
    Rep Power
    1
    A quick and easy solution to the issue is to use two xpath commands:

    <remove xpath="//property" />
    <append xpath="//property/@value>50</append>

    The remove should fail silently if its not there, and remove if it its there. the append would put it back.

  11. #26
    Colony Founder Kubikus's Avatar
    Join Date
    Apr 2015
    Posts
    1,418
    Rep Power
    1
    Quote Originally Posted by sphereii View Post
    A quick and easy solution to the issue is to use two xpath commands:

    <remove xpath="//property" />
    <append xpath="//property/@value>50</append>

    The remove should fail silently if its not there, and remove if it its there. the append would put it back.
    Like so?

  12. #27
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,829
    Rep Power
    1
    Probably something like this:

    Code:
    <remove xpath="/blocks/block[@name='woodFrameWedge']/property[@name='MaxDamage']" />
    <append xpath="/blocks/block[@name='woodFrameWedge']">
          <property name="MaxDamage" value="75" >
    </append>
    If you aren't appending specifically to a value, but rather an entirely new line, it'll be the slightly longer format.

  13. #28
    Colony Founder Kubikus's Avatar
    Join Date
    Apr 2015
    Posts
    1,418
    Rep Power
    1
    Quote Originally Posted by sphereii View Post
    Probably something like this:

    Code:
    <remove xpath="/blocks/block[@name='woodFrameWedge']/property[@name='MaxDamage']" />
    <append xpath="/blocks/block[@name='woodFrameWedge']">
          <property name="MaxDamage" value="75" >
    </append>
    If you aren't appending specifically to a value, but rather an entirely new line, it'll be the slightly longer format.
    Ah, yes, my mistake, you had explained that already. Thanks.

  14. #29
    Colony Founder meganoth's Avatar
    Join Date
    Mar 2017
    Posts
    3,058
    Rep Power
    1
    Exellent intro.


    Possible bug report:

    You used append once with and once without comma. I assume only one method is correct.

    Code:
    <append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">,NoAmmo</append>
    
    <append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">NoAmmo</append>

  15. #30
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,829
    Rep Power
    1
    Quote Originally Posted by meganoth View Post
    Exellent intro.


    Possible bug report:

    You used append once with and once without comma. I assume only one method is correct.

    Code:
    <append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">,NoAmmo</append>
    
    <append xpath="/items/item/property[@class='Action0']/property[@name='Magazine_items'][@value='9mmBullet']/@value">NoAmmo</append>
    yes, the first one is correct. I'll update the post. It appends as a string, so it doesn't know any context on what it's changing.

Posting Permissions

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