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

Video Tutorial : XPath Modding for Beginners.

extra content at end of line 7

thanks, i think i am doing this right. I made admin tools and then an admin starter kit. I think i appended this to the entity classes right but notepadd++ keeps saying the middle xpath has extra content at the end of line 7.

Code:
<?xml version="1.0" encoding="UTF-8"?>

<DWModsAdminMod>

<set xpath="/entity_classes/entity_class/[@name="playerMale"]/property[@name="ItemsOnEnterGame.GameModeSurvival" ]/@valueadminsuperbag</set>
<set xpath="/entity_classes/entity_class/[@name="playerMale"]/property[@name="ItemsOnEnterGame.GameModeSurvivalSP" ]/@valueadminsuperbag</set>
<set xpath="/entity_classes/entity_class/[@name="playerMale"]/property[@name="ItemsOnEnterGame.GameModeSurvivalMP" ]/@valueadminsuperbag</set>

</DWModsAdminMod>
ooh i fixed it, i used double quote where i should have used single.

Code:
<DWModsAdminMod>

<set xpath="/entity_classes/entity_class[@name='playerMale']/property[@name='ItemsOnEnterGame.GameModeSurvival']/@value">adminsuperbag</set>
<set xpath="/entity_classes/entity_class[@name='playerMale']/property[@name='ItemsOnEnterGame.GameModeSurvivalSP']/@value">adminsuperbag</set>
<set xpath="/entity_classes/entity_class[@name='playerMale']/property[@name='ItemsOnEnterGame.GameModeSurvivalMP']/@value">adminsuperbag</set>

</DWModsAdminMod>
thank you so very much for your video

 
Last edited by a moderator:
so i've run into a snag with running <append xpath=/lootcontainer>

it is not recognizing items in the loot list, even vanilla items copied over exactly from the vanilla files.

i'm trying to make this starter bag by Valmod https://7daystodie.com/forums/showthread.php?31157-Survivor-s-Pack-Starting-Gear&highlight=starter+pack and everything else loads and parses perfectly, except the loot in the lootlists on the lootcontainer page.

any Ideas?

Code:
<?xml version="1.0" encoding="UTF-8"?>

<DWModsAdminMod>

<append xpath="/lootcontainers">


<!--small Loot-->

<lootgroup name="adminCoin" count="all">
    <item group="meleeBoneShiv" count="4"/>
   <item group="modArmorTripleStoragePocket" count="4"/>
   <item group="cntSecureStorageChest" count="4"/>	
</lootgroup>
its saying the boneshive doesnt exist. i swapped out casinocoins for a boneshive in case my admin coins that extended the casino coins were the issue.

thanks for your help

 
Last edited by a moderator:
Do you have an item group named meleeBoneShiv ?

I am assuming you want

Code:
<lootgroup name="adminCoin" count="all">
   <item name="meleeBoneShiv" count="4"/>
   <item name="modArmorTripleStoragePocket" count="4"/>
   <item name="cntSecureStorageChest" count="4"/>    
</lootgroup>
 
Do you have an item group named meleeBoneShiv ?

I am assuming you want

Code:
<lootgroup name="adminCoin" count="all">
   <item name="meleeBoneShiv" count="4"/>
   <item name="modArmorTripleStoragePocket" count="4"/>
   <item name="cntSecureStorageChest" count="4"/>    
</lootgroup>
i fixed that error several hour ago. Thanks!

though its still bugged, cant get it to spawn the loot when i break the first container. and most container models completely break the game when used. but I've been up doing coding and manual labor for 24 hours straight now. So i'll try to tackle the refusal to spawn loot issue tomorrow.

 
May I suggest you get this mod and make it do what you want. Most of the legwork is already done for you, unless you are just trying to learn.

Here

I think it is a good practice when working with loot to use insertAfter and Before. loot can be tricky sometimes.

This will insert after the last vanilla group and then after the last vanilla container, I used "249". I think 250 is max

Code:
<configs>
<insertAfter xpath="/lootcontainers/lootgroup[@name='BuriedStashChest']">
<lootgroup name="adminCoin" count="all">
   <item name="meleeBoneShiv" count="4"/>
   <item name="modArmorTripleStoragePocket" count="4"/>
   <item name="cntSecureStorageChest" count="4"/>  
</lootgroup>
</insertAfter>


<insertAfter xpath="/lootcontainers/lootcontainer[@id='116']">


<lootcontainer id="249" count="1" size="8,9" sound_open="UseActions/open_cardboard" sound_close="UseActions/close_cardboard" loot_quality_template="treasureTemplate" destroy_on_close="true">
<item group="adminCoin"/>
</lootcontainer>
</insertAfter>
</configs>
 
May I suggest you get this mod and make it do what you want. Most of the legwork is already done for you, unless you are just trying to learn.
Here

I think it is a good practice when working with loot to use insertAfter and Before. loot can be tricky sometimes.

This will insert after the last vanilla group and then after the last vanilla container, I used "249". I think 250 is max

Code:
<configs>
<insertAfter xpath="/lootcontainers/lootgroup[@name='BuriedStashChest']">
<lootgroup name="adminCoin" count="all">
   <item name="meleeBoneShiv" count="4"/>
   <item name="modArmorTripleStoragePocket" count="4"/>
   <item name="cntSecureStorageChest" count="4"/>  
</lootgroup>
</insertAfter>


<insertAfter xpath="/lootcontainers/lootcontainer[@id='116']">


<lootcontainer id="249" count="1" size="8,9" sound_open="UseActions/open_cardboard" sound_close="UseActions/close_cardboard" loot_quality_template="treasureTemplate" destroy_on_close="true">
<item group="adminCoin"/>
</lootcontainer>
</insertAfter>
</configs>
thank you for upselling your mods.

I've made this mod before, multiple times, and i havnt had this issue since the first time i made it. I dont remember how i fixed it then.

I've been modding for over 3 years now, not an expert like some other fantastic people here but, 1. I need more coding experience in gaming. 2. I want stuff on my server to be coded by me. 3. I want everything on my server to be exclusive. 4. I want to make sure the modlets I make are compatible with each other and if I build this overhaul out of modlets I know how to not create redundancies and conflicts. I've spent a week dividing up my planned 20 mods into non-conflicting modlets prior to coding them. and Ive put close to 24 hours into coding this single modlet because I pay attention to detail. lastly, this modlet is a template for 3 other similar mods for my server.

 
Last edited by a moderator:
I don't think he was upselling his mod at all (especially since it wasn't his mod), I think his advice is sound.

You can have all the experience in the world, but he's right... looking at other people's work is by far the best way to learn.

 
I'm a big fan of yours and Valmods work and spend quite a bit of time referencing your code. Still rather write my own, at least for the experience and to make sure its doing what i want it to do. as i've said before, I've written this piece before. it worked beautifully. Then my teenage stepson got angry we said no and snuck into my office one night and deleted a ♥♥♥♥ ton of stuff off my computer, my 7dtd folder of mods being one of those things, among many programs and games. most of it was super easy to redownload, my modding folder wasnt so much.

 
Last edited by a moderator:
so i am getting this error

Code:
2019-03-25T23:13:02 62.173 ERR XML loader: Patching 'recipes.xml' from mod 'DW Mods - Dyes Mod' failed
2019-03-25T23:13:02 62.174 EXC XML.Patch (/append/recipe): Patch element does not have an 'xpath' attribute
Exception: XML.Patch (/append/recipe): Patch element does not have an 'xpath' attribute
 at XmlPatcher.singlePatch (.XmlFile _targetFile, System.Xml.XmlElement _patchElement, System.String _patchName) [0x00000] in <filename unknown>:0 
 at XmlPatcher.PatchXml (.XmlFile _xmlFile, .XmlFile _patchXml, System.String _patchName) [0x00000] in <filename unknown>:0 
 at XmlPatcher.LoadAndPatchConfig (System.String _configName) [0x00000] in <filename unknown>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Logger:masterLogException(Exception)
Logger:Exception(Exception)
Log:Exception(Exception)
XmlPatcher:LoadAndPatchConfig(String)
<loadSingleXml>c__Iterator1:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
and my code looks like this

Code:
<?xml version="1.0" encoding="UTF-8" ?>

<!--recipes-->

<append xpath="/recipes">

blah blah blah

</append>
I copied and pasted the xpath code over from the items one for this mod and the items one has no errors. I've also ran the code through a validator, used ccleaner on my computer, validated the steam files, and started a brand new game. It still says the xpath file isnt coded. any ideas why?

 
I haven't, been responding to most questions on my Discord.

And to respond to the first post on this page, he needs an xml tag wrapping the entire mod,

like this

<somenamehere>

<append...>

</append>

</somenamehere>

 
Last edited by a moderator:
May I suggest you get this mod and make it do what you want. Most of the legwork is already done for you, unless you are just trying to learn.
Here

I think it is a good practice when working with loot to use insertAfter and Before. loot can be tricky sometimes.

This will insert after the last vanilla group and then after the last vanilla container, I used "249". I think 250 is max

Code:
<configs>
<insertAfter xpath="/lootcontainers/lootgroup[@name='BuriedStashChest']">
<lootgroup name="adminCoin" count="all">
<item name="meleeBoneShiv" count="4"/>
<item name="modArmorTripleStoragePocket" count="4"/>
<item name="cntSecureStorageChest" count="4"/>
</lootgroup>
</insertAfter>


<insertAfter xpath="/lootcontainers/lootcontainer[@id='116']">


<lootcontainer id="249" count="1" size="8,9" sound_open="UseActions/open_cardboard" sound_close="UseActions/close_cardboard" loot_quality_template="treasureTemplate" destroy_on_close="true">
<item group="adminCoin"/>
</lootcontainer>
</insertAfter>
</configs>
sadly this github is not longer available.

 
somebody please refresh my memory because its been so long sine I've written xpath, am I missing something here?

<modSurvivorsKit>

<set xpath="/entity_classes/entity_class[@name=playerMale]/property[@name=ItemsOnEnterGame.GameModeSurvival]/@value">hitMe,meleeTorch,keystoneBlock,meleeToolSt oneAxeTazas</set>

<set xpath="/entity_classes/entity_class[@name=playerMale]/property[@name=ItemsOnEnterGame.GameModeSurvivalSP]/@value">hitMe,meleeTorch,keystoneBlock,meleeToolSt oneAxeTazas</set>

<set xpath="/entity_classes/entity_class[@name=playerMale]/property[@name=ItemsOnEnterGame.GameModeSurvivalMP]/@value">hitMe,meleetorch,keystoneBlock,meleeToolSt oneAxeTazas</set>

</modSurvivorsKit>
 
I haven't, been responding to most questions on my Discord.
And to respond to the first post on this page, he needs an xml tag wrapping the entire mod,

like this

<somenamehere>

<append...>

</append>

</somenamehere>
discord? how might i findd you there?

 
Tutorial is still very valid, all the information on XPATH still applies. I updated the title and thumbnail of the video to reflect it applies to the game in general now not just a specific Alpha. And unless the devs dramatically change the system should apply for the foreseeable future.

Discord link in is the about page of my channel.

 
Thank you for adding the video tutorial. I think I learn better by example using visual means with reading as extra support.

Just something very simple as it's all a bit of a blur in there while I learn the terminology, hierarchy, dependencies, and all manner of others.

Exploding Zombie Bones

These bones have replaced the crossbow stone bolt ammo and have also taken a little bit from the exploding crossbow bolts for good effect. I wanted to use chickens but I have no idea how to take the model over to the items. Using bones was much easier because it is already in the same items hierarchy for that area. In any case, Potassium Nitrate is found when harvesting rotten carcasses and those Zombie Bones could fit this context better :)

Following the tutorial, I could see how we can grab XPath code from one area and apply it to a mod.

A few (low quality resolution) pikkies to show the effect.

Load up your explosive bone.

20200818225539_1.jpg

Take aim and fire.

20200818225553_1.jpg

Load up again.

20200818225558_1.jpg

It's over.

20200818225616_1.jpg

The impact is the same as high explosive bolts so very familiar.

20200818232448_1.jpg


Here is the code if anyone is interested.

ModInfo.xml

<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<ModInfo>
<Name value="Exploding Zombie Bones" />
<Description value="XPath Modding for Beginners by Buggi - Exploding zombie bones to replace stone bolts." />
<Author value="arramus" />
<Version value="A19" />
<Website value="https://community.7daystodie.com/topic/9538-video-tutorial-xpath-modding-for-beginners/" />
</ModInfo>
</xml>


Config/items.xml

<modtutorial>
<append xpath="/items">
<item name="ammoCrossbowBoltStone">
<property name="Tags" value="ammo,ranged,attAgility,perkArchery,perkPenetrator"/>
<property name="DisplayType" value="ammoArrow"/>
<property name="Meshfile" value="#Other/Items?Crafting/femur.fbx"/>
<property name="HoldType" value="45"/>
<property name="HandMeshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
<property name="Material" value="Mwood"/>
<property name="IsSticky" value="true"/>
<property name="StickyOffset" value=".1"/>
<property name="StickyColliderUp" value="2"/>
<property name="StickyColliderRadius" value=".05"/>
<property name="StickyColliderLength" value=".75"/>
<property name="Stacknumber" value="150"/> <!-- STK ammo low -->
<property name="FuelValue" value="8"/>
<property name="EconomicValue" value="12"/>
<property name="EconomicBundleSize" value="5"/>
<property name="Group" value="Ammo/Weapons"/>
<property class="Action1">
<property name="Class" value="Projectile"/>
<property name="Explosion.ParticleIndex" value="11"/>
<property name="Gravity" value="-3"/>
<property name="FlyTime" value="0"/>
<property name="LifeTime" value="14"/>
<!-- <property name="DamageBonus.earth" value="0"/>
<property name="DamageBonus.metal" value="0"/>
<property name="DamageBonus.cloth" value="0"/> -->
</property>

<effect_group name="ammoCrossbowBoltExploding" tiered="false"> <!-- ammoCrossbowBoltExploding -->
<passive_effect name="EntityDamage" operation="base_set" value="65"/>
<passive_effect name="BlockDamage" operation="base_set" value="1"/>
<passive_effect name="DamageModifier" operation="perc_set" value=".1" tags="wood"/>
<passive_effect name="DamageModifier" operation="perc_set" value="0" tags="earth,metal,cloth"/>
<passive_effect name="ProjectileVelocity" operation="base_set" value="67.5"/>
</effect_group>
</item>
</append>
</modtutorial>


The damage was lowered to 65 and this lets the zombies with higher 'health' recover while lower 'health' zombies are down in one shot.

Things I would like to do with this for the future are:

- Make harvesting carcass bones provide exploding bone ammo as standalone just like finding regular ammo.

- Make the bones align better in the crossbow.

- Add it for the bows.

- Tweak and balance. (Self damage, reduce damage for low level players, remove ability to use scope, etc.)

I did hit a chicken from 30 or so meters away and it was an obvious hit with the explosion. The chicken carcass remained intact for harvesting.

Once again, thanks again for the tutorial. I am actually only a little bit in as the introductory recipe section made me want to try something out.

 
Back
Top