Results 1 to 12 of 12

Thread: What the frack is wrong with my mod ?

  1. #1
    Hunter
    Join Date
    Nov 2015
    Location
    Canada
    Posts
    104
    Rep Power
    0

    What the frack is wrong with my mod ?

    <!-- Blocks.xml, traps, sets damage received from operation to 0 -->
    <!-- <property name="DamageReceived" value=""/> -->
    <!-- <property name="Damage_received" value=""/> -->

    <!-- Code -->
    <configs>
    <set xpath="/blocks/block/property[@name='Damage_received']/@value">0</set>
    <set xpath="/blocks/block/property[@name='DamageReceived']/@value">0</set>
    </configs>

    This SHOULD parse the entire blocks.xml and replace the damage received value for every block with that attribute but its not and its driving me up the wall. I have looked at everything I can think of, even the case of the filename... I'm ready to punch my screen ! It works if I change the core file so I know the property still functions but this xpath won't to a thing.

  2. #2
    Survivor psouza4's Avatar
    Join Date
    Dec 2014
    Location
    Meridian, Idaho, USA
    Posts
    97
    Rep Power
    0
    I'm not sure you can bulk set all the blocks this way, but if you can it should be setattribute (not set). You're setting the attribute of the value of those xml lines, not the content.

  3. #3
    Hunter
    Join Date
    Nov 2015
    Location
    Canada
    Posts
    104
    Rep Power
    0
    Quote Originally Posted by psouza4 View Post
    I'm not sure you can bulk set all the blocks this way, but if you can it should be setattribute (not set). You're setting the attribute of the value of those xml lines, not the content.
    I picked up everything I know about xpath from Sphereii' post
    https://7daystodie.com/forums/showth...anation-Thread
    Set and advanced conditionals are covered in the 4th and 5th posts, in this case, the condition is that it contain one of the two damage received values... I had it set up as an or conditional at one point but it wasn't working either.

    <configs>
    <set xpath="/blocks/block/property[@name='Damage_received' or @name='DamageReceived']/@value">0</set>
    </configs>

    As far as I can tell, everything LOOKS right, it doesn't even throw warnings in the console on load.

    --------------------
    Rereading that post, I think I might have something though...

  4. #4
    Survivor psouza4's Avatar
    Join Date
    Dec 2014
    Location
    Meridian, Idaho, USA
    Posts
    97
    Rep Power
    0
    Like I said, setattribute, not set.

  5. #5
    Inventor Sirillion's Avatar
    Join Date
    Dec 2015
    Location
    Norway
    Posts
    903
    Rep Power
    1
    Quote Originally Posted by psouza4 View Post
    Like I said, setattribute, not set.
    I am afraid he is correct with using set in this one as he is changing an already existing attribute to a new value. Setattribute would be used if he is adding a new attribute, and value, to the blocks.

    The difference:

    Code:
    <set xpath="/xui/ruleset[@name='default']/window_group[@name='workstation_campfire']/window[1]/@name">newname</set>
    This would change the first window name in the xui.xml file for the workstation_campfire window to newname.

    Code:
    <setattribute xpath="/xui/ruleset[@name='default']/window_group[@name='workstation_campfire']/window[1]" name="anchor">CenterTop</setattribute>
    This would add the attribute anchor to the first window name in the xui.xml file for the workstation_campfire window and give that the value CenterTop.

    That said, the code he is posting works just fine, it sets the attributes to 0 so there should be nothing wrong with the code, this can be verified by using exportcurrentconfigs in the console ingame and checking the files it creates for the changes.

    On the other hand, what do you expect to happen when it is set to 0? And can it be set to 0?

  6. #6
    Hunter
    Join Date
    Nov 2015
    Location
    Canada
    Posts
    104
    Rep Power
    0
    Quote Originally Posted by psouza4 View Post
    Like I said, setattribute, not set.
    From what I've been reading, set is used to change an existing value while setattribute is used to create one with its value.

    From Sphereii's tutorial.
    <setattribute xpath="">
    - Allows you to add a new attribute
    Example:
    This adds a new max_level attribute to the attribute with the name attPerception
    Code:
    <setattribute xpath="/progression/attributes/attribute[@name='attPerception']" name="max_level">1000</setattribute>

    VS

    <set xpath="">
    - Allow you to change a value
    Example:
    This line changes loot container id 62, and changes it's size to 7,6.
    Code:
    <set xpath="/lootcontainers/lootcontainer[@id='62']/@size">7,6</set>

    What it would look like <setattribute xpath="/blocks/block/property[@name='DamageReceived' or @name='Damage_received']" name="value">0</setattrbute> and I imagine it would create a duplicate property named "value" with the value of 0 like this in the code <property name="DamageReceived" value="4" value="0"/>

    At any rate, that didn't work either, so something else is going wrong :/

  7. #7
    Hunter
    Join Date
    Nov 2015
    Location
    Canada
    Posts
    104
    Rep Power
    0
    Quote Originally Posted by Sirillion View Post
    On the other hand, what do you expect to happen when it is set to 0? And can it be set to 0?
    Setting it to 0 in the core file works like a charm, the value exists and can be changed, the result is the traps in question take 0 operational damage, they normally degrade as they damage enemies... there is however something wrong with my code or the implementation of the modlet...
    I have other modlets that work as intented and look pretty much the same regard to file structure so I have no idea why its not producing the intended results.
    Where does that exportcurrentconfigs dump the files ? Ill have to give it a look.

    This is what it looks like now and it doesn't work...
    <configs>
    <!-- Blocks.xml, traps, sets damage received from operation to 0 -->
    <!-- <property name="DamageReceived" value=""/> -->
    <!-- <property name="Damage_received" value=""/> -->
    <set xpath="/blocks/block/property[@name='DamageReceived' or @name='Damage_received']/@value">0</set>
    </configs>
    Last edited by Atrophied; 3 Weeks Ago at 06:44 AM.

  8. #8
    Inventor Sirillion's Avatar
    Join Date
    Dec 2015
    Location
    Norway
    Posts
    903
    Rep Power
    1
    Quote Originally Posted by Atrophied View Post
    Setting it to 0 in the core file works like a charm, the value exists and can be changed, the result is the traps in question take 0 operational damage, they normally degrade as they damage enemies... there is however something wrong with my code or the implementation of the modlet...
    I have other modlets that work as intented and look pretty much the same regard to file structure so I have no idea why its not producing the intended results.
    Where does that exportcurrentconfigs dump the files ? Ill have to give it a look.

    This is what it looks like now and it doesn't work...
    <configs>
    <!-- Blocks.xml, traps, sets damage received from operation to 0 -->
    <!-- <property name="DamageReceived" value=""/> -->
    <!-- <property name="Damage_received" value=""/> -->
    <set xpath="/blocks/block/property[@name='DamageReceived' or @name='Damage_received']/@value">0</set>
    </configs>
    The code works, I tested it and checked the dump and the value is indeed set to 0. It tells you where it dumps when you do the command.

  9. #9
    Scavenger
    Join Date
    Mar 2015
    Posts
    34
    Rep Power
    0
    Not sure if it still works for A18 but I did this for A17 and it worked for me during that alpha.
    Code:
    <config>
    	<!--Changes the damage taken when dealing damage for the Blade Trap-->
    	<set xpath="/blocks/block[@name='bladeTrap']/property[@name='DamageReceived']/@value">0</set>
    	
    	<!--Changes the damage taken when dealing damage for Electric Fence Posts-->
    	<set xpath="/blocks/block[@name='electricfencepost']/property[@name='DamageReceived']/@value">0</set>
    	
    	<!--Changes the damage taken when dealing damage for Wooden spikes-->
    	<set xpath="/blocks/block[@name='trapSpikesWoodMaster']/property[@name='Damage_received']/@value">0</set>
    	
    	<!--Changes the damage taken when dealing damage for Scrap Iron Spikes-->
    	<set xpath="/blocks/block[@name='trapSpikesScrapIronMaster']/property[@name='Damage_received']/@value">0</set>
    	
    	<!--Changes the damage taken when dealing damage for Wooden Log Spike-->
    	<set xpath="/blocks/block[@name='woodLogSpike1']/property[@name='Damage_received']/@value">0</set>
    	
    	<!--Changes the damage taken when dealing damage for Reinforced Wooden Log Spike-->
    	<set xpath="/blocks/block[@name='rWoodLogSpike2']/property[@name='Damage_received']/@value">0</set>
    
    	<!--Changes the damage taken when dealing damage for metal Reinforced Wooden Log Spike-->
    	<set xpath="/blocks/block[@name='rWoodMetalLogSpike3']/property[@name='Damage_received']/@value">0</set>
    	
    	<!--Changes the damage taken when dealing damage for scrap Iron Log Spike-->
    	<set xpath="/blocks/block[@name='scrapIronLogSpike4']/property[@name='Damage_received']/@value">0</set>
    
    	<!--Changes the damage taken when dealing damage for Reinforced Scrap Iron Log Spike-->
    	<set xpath="/blocks/block[@name='rScrapIronLogSpike5']/property[@name='Damage_received']/@value">0</set>
    
    	<!--Changes the damage taken when dealing damage for Steel Log Spike-->
    	<set xpath="/blocks/block[@name='steelLogSpike6']/property[@name='Damage_received']/@value">0</set>
    
    	<!--Changes the damage taken when dealing damage for New Spike Traps(those crafted with forged metal probably)-->
    	<set xpath="/blocks/block[@name='trapSpikesNew']/property[@name='Damage_received']/@value">0</set>
    
    	<!--Changes the damage taken when dealing damage for Barbed Wire(no fence)-->
    	<set xpath="/blocks/block[@name='barbedWireSheet']/property[@name='Damage_received']/@value">0</set>
    
    	<!--Changes the damage taken when dealing damage for Barbed Wire(fence)-->
    	<set xpath="/blocks/block[@name='barbedFence']/property[@name='Damage_received']/@value">0</set>
    
    </config>
    Added all kind of traps even those that wasn't craftable. Hope this works if you can't get yours to work.

  10. #10
    Hunter
    Join Date
    Nov 2015
    Location
    Canada
    Posts
    104
    Rep Power
    0

    Quote Originally Posted by Sirillion View Post
    The code works, I tested it and checked the dump and the value is indeed set to 0. It tells you where it dumps when you do the command.
    Thanks for the test, knowing the code works helps. I think I found the problem in the file structure with an extra letter in the folder name that I missed before :/
    It should work for me now.

    EDIT: Aaaaaan ... it works. Turns out I had the "config" folder named "configs", so no warnings, it was successfully loading nothing... I hang my head in shame now
    Last edited by Atrophied; 3 Weeks Ago at 01:05 PM.

  11. #11
    Refugee
    Join Date
    Dec 2018
    Posts
    20
    Rep Power
    0
    i made a similar mistake last week, having a mod file called buff.xml, not buffs.xml.

  12. #12
    Hunter
    Join Date
    Nov 2015
    Location
    Canada
    Posts
    104
    Rep Power
    0

    Quote Originally Posted by adverserath View Post
    i made a similar mistake last week, having a mod file called buff.xml, not buffs.xml.
    Coders nightmare... we search the code top to bottom and pull out our hair... turns out its not even the code

Posting Permissions

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