Jump to content

What the frack is wrong with my mod ?


Atrophied

Recommended Posts

<!-- 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.

Link to comment
Share on other sites

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/showthread.php?93816-XPath-Modding-Explanation-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...

Link to comment
Share on other sites

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:

 

<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.

 

<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?

Link to comment
Share on other sites

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 :/

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Not sure if it still works for A18 but I did this for A17 and it worked for me during that alpha.

<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.

Link to comment
Share on other sites

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 :02.47-tranquillity:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...