• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

SOLVED - Adding "destroy on close" to items...

Wacko

Refugee
Hiya guys/gals,

Relatively new to modding, can read xml's etc and have tinkered for years with others but trying something new for a change.

<!-- metal garbage can-->
<lootcontainer name="garbage" count="1,2" size="6,2" sound_open="UseActions/open_trashcan" sound_close="UseActions/close_trashcan" loot_quality_template="qualBaseTemplate">
<item group="groupGarbage"/>
</lootcontainer>




How do I create a modlet to add the code destroy_on_close="true" to it? I have looked at the code from a modlet all ready about adding loot and destroying on close to the wine barrels but can't for the life of me work out how to add destroy on close for the garbage can that all ready has a loot table. I tried the below but I get a red error saying "EXC Duplicate lootlist entry with name garbage"

<!-- metal garbage can-->
<append xpath="/lootcontainers">
<lootcontainer name="garbage" count="1,2" size="6,2" sound_open="UseActions/open_trashcan" sound_close="UseActions/close_trashcan" loot_quality_template="qualBaseTemplate" destroy_on_close="true">
<item group="groupGarbage"/>
</lootcontainer>
</append>




SOLVED

<remove xpath="/lootcontainers/lootcontainer[@name='garbage']" />

<append xpath="/lootcontainers">
<lootcontainer name="garbage" count="1,2" size="6,2" sound_open="UseActions/open_trashcan" sound_close="UseActions/close_trashcan" loot_quality_template="qualBaseTemplate" destroy_on_close="true">
<item group="groupGarbage"/>
</lootcontainer>
</append>




** Posted in wrong forum, sorry, don't know how to delete or move **

 
Last edited by a moderator:
Sorry I didn’t see this earlier, but another way is to use setattribute when you are adding a new attribute to a node.

 
Thanks mate, I guess the way I did it isn’t optimal, but it worked.
 

How would setattribute work when the destroy isn’t there to begin with? These xml edits take a bit getting use to but I’m trying.

 
Setattribute would add the destroy on close variable to the node itself.  So as an example

<setattribute xpath="//lootcontainer[@name='hardenedChestT5']" name="destroy_on_close">true</setattribute>




So assuming I got my pathing right, if you were to enter this code, the T5 reinforced loot chests would now get the destroy on close variable and would behave like a nest now after you loot and close it.

Thanks mate, I guess the way I did it isn’t optimal, but it worked.


Yeah, not optimal which is why I said it was another way.  This way you don't have to remove the code first, and then re-enter it again (reduces your 7 lines of code down to 1 in this example).

Another advantage of doing it this way if in future updates they make some minor changes to the other parts of it, your code would still work (most of the time).

 
Setattribute would add the destroy on close variable to the node itself.  So as an example

<setattribute xpath="//lootcontainer[@name='hardenedChestT5']" name="destroy_on_close">true</setattribute>




So assuming I got my pathing right, if you were to enter this code, the T5 reinforced loot chests would now get the destroy on close variable and would behave like a nest now after you loot and close it.

Yeah, not optimal which is why I said it was another way.  This way you don't have to remove the code first, and then re-enter it again (reduces your 7 lines of code down to 1 in this example).

Another advantage of doing it this way if in future updates they make some minor changes to the other parts of it, your code would still work (most of the time).


You my friend are a champ :)  Just edited and all works a treat. Cheers for the help.

 
Back
Top