Introduction[]
In this section we will go over creating a very basic mod for 7 Days to Die (v1.1 +). It will be the simplest type of mod, which just modifies some of the parameters of existing game objects.
Specifically, we will make the nice wooden doors found on prefabs available as craftable items for the player.
Files and Folder Structure[]
To begin with, we will need some very specific folders and files for our mod.
- First we need the root folder of the mod. I'm just going to create a folder called "MoreDoors".
- Within that folder, create a subfolder called "config". This is where the actual configuration files will go. This is the only subfolder we need, because for this mod we are not adding any new assets to the game, just modifying existing assets.
- Now create a new text file called "ModInfo.xml" in the root of MoreDoors.
- Create three (3) text files in the config folder, called: blocks.xml, Localization.xml, and recipes.xml.
That's all we need for this simple mod. I'll explain the use of each file as we continue. Your folder structure should look like this:
MoreDoors \config \blocks.xml \Localization.txt \recipes.xml \ModInfo.xml
What is Xpath?[]
Xpath is a way of finding information in xml files, and modifying values in those xml files. In the context of our 7 Days to Die mod, it will allow us to change some of the parameters set by the main game, when the game loads up.
Xpath uses a very specific syntax, which I'm not going to document here. (See: XPath Explained) But to help understand it, think of an XML file as almost being like a folder structure in your computer's file system.
You can have items that contain subitems, and value assignments. For example, a <block> item can have a bunch of attributes under it, which you could think of like:
\block\attribute
Xpath uses that sort of syntax for finding, adding, removing, and changing attributes of things in the game.
You can easily search online for more assistance on using Xpath.
Modinfo.xml[]
Before going on, it's important to stay up to date with current updates on 7 Days to Die, as much has changed in regards to modding, with the V1.0 update, we are to change the way our ModInfo.xml is. You can see the current format, which you MUST follow for your mod to work in-game.
PLEASE READ:
At the top of ModInfo.xml you are to include the following on Line 1:
<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<Name value="yourUniqueIdentifier" />
<DisplayName value="My new mod name" />
<Version value="0.0.0.0" />
<Description value="Your mods description goes here" />
<Author value="xMisterDan" />
<Website value="" />
</xml>
You must ensure that there are NO SPACING between lines of code, assuring that the code can be read fluently without hiccup, which can improve overall performance.
config\blocks.xml[]
This is where the fun begins. To start with, we're going to first look at the configuration of the doors in the base game. To do so, I searched for "Door" in the file blocks.xml that I found in my 7D installation directory.
I located this:
<block name="houseFrontDoor1_v1">
I also located a section for the doors that players can already craft in the game:
<block name="secureDoorWooden">
So now I have two important things: What a craftable door looks like, and what the uncraftable door that I want to make craftable looks like. Yay!
I also noted that there's several versions of each of these two things:[]
<block name="secureDoorWooden"> <block name="secureReinforcedDoorWooden"> <block name="metalReinforcedDoorWooden">
And
<block name="houseFrontDoor1_v1"> <block name="houseFrontDoor1_v2"> <block name="houseFrontDoor1_v3">
And also there's a houseFrontDoor2 set with the same three versions.[]
Digging into those sections, I see this interesting section:[]
<property class="UpgradeBlock">
<property name="ToBlock" value="houseFrontDoor1_v2"/>
<property name="Item" value="resourceWood"/>
<property name="ItemCount" value="4"/> <property name="UpgradeHitCount" value="4"/>
</property>
So this tells us that those three versions are the three possible upgrades for the door. v1 is the unreinforced door, v2 is the wood reinforced door, and v3 is the metal reinforced door.
Now, looking at the two block groups, I noted several attributes that appear on the secureDoorWooden set that are missing from the houseFrontDoor set:
- MaxDamage - How much damage can it take?
- FuelValue - How long will it fuel a campfire or a forge?
- CustomIcon - What does it look like in your inventory.
- TakeDelay - How long it takes to pick something up
- Group - Refers to the "Item Group" field displayed in the infobox of an item. It also matches the grouping of crafting recipes.
- EconomicValue - What is it worth to a vendor?
- EconomicBundleSize - How many of them can we stack?
So what we need to do is insert those attributes into the definitions for the Front Doors. We'll use the Xpath directive "setattribute" to insert new attributes into those blocks (in the config/blocks.xml file):
<configs>
<append xpath="/setattribute">
<setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="MaxDamage">250</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="FuelValue">200</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="CustomIcon">houseFrontDoor1_v1</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="TakeDelay">10</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="Group">Building,advBuilding</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="EconomicValue">10</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="EconomicBundleSize">10</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="MaxDamage">250</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="FuelValue">200</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="CustomIcon">houseFrontDoor1_v1</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="TakeDelay">10</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="Group">Building,advBuilding</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="EconomicValue">10</setattribute>
<setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="EconomicBundleSize">10</setattribute>
</append>
</configs>
We won't worry about the v2 and v3 sections, since we don't plan on players being able to remove the reinforced doors without first demolishing them down to the base door.
Also, for the CustomIcon, I found the picture I wanted in the /data/ItemIcons folder within the 7D install folder, and used the name of the picture that was appropriate.
config\Localization.txt[]
This file is pretty simple. We need to provide the text for the item as it appears in the crafting menus. So in your Localization.txt file, we should have these lines:
Key,Source,Context,Changes,English,French,German,Klingon,Spanish houseFrontDoor1_v1,blocks,Door,,Front Door,Porte avant,Eingangstür,chob,Puerta houseFrontDoor2_v1,blocks,Door,,Front Door,Porte avant,Eingangstür,chob,Puerta
We only need these for the v1 doors because the player won't be crafting the reinforced doors directly. (And hey, if someone knows the French, German and Spanish for "Front Door" feel free to update this tutorial!)
config\recipes.xml[]
Finally, we want to make a way for the players to craft the doors. In this case we'll use the xpath "append" method to add some new recipes to the game. Looking at the main recipes.xml file in the 7 Days to Die install folder, we can see that it's a really simple section:
<recipe name="secureDoorWooden" count="1">
<ingredient name="resourceWood" count="4"/>
</recipe>
So what do we want to use? Just for our example, let's say a brass doorknob, some brass bits (that would be hinges) and some wood. Another quick search through the recipes and I find the three resource names I want:
- resourceWood
- resourceScrapBrass
- resourceDoorKnob
So we add those as items required for our recipe, and we get the following recipe:
<recipe name="houseFrontDoor1_v1" count="1" craft_time="10" craft_area="workbench" tags="workbenchCrafting">
<ingredient name="resourceWood" count="6"/>
<ingredient name="resourceScrapBrass" count="2"/>
<ingredient name="resourceDoorKnob" count="1"/>
</recipe>
Do the same for the houseFrontDoor2_v1, and then use the xpath Append function to give us a final recipes.xml file that looks like this:
<configs>
<append xpath="/recipes">
<recipe name="houseFrontDoor1_v1" count="1" craft_area="workbench">
<ingredient name="resourceWood" count="6"/>
<ingredient name="resourceScrapBrass" count="2"/>
<ingredient name="resourceDoorKnob" count="1"/>
</recipe> <recipe name="houseFrontDoor2_v1" count="1" craft_area="workbench">
<ingredient name="resourceWood" count="6"/>
<ingredient name="resourceScrapBrass" count="2"/>
<ingredient name="resourceDoorKnob" count="1"/>
</recipe>
</append>
</configs>
Wrapping up[]
Ok, so we should now have four files within our MoreDoors folder:
- \ModInfo.xml
- configs\blocks.xml
- configs\Localization.txt
- configs\recipes.xml
That's all there is! Copy that whole MoreDoors folder into a "Mods" folder within your 7 Days to Die main installation, and give it a try!
You might want to actually add a recipe to craft doorknobs rather than waiting to scavenge them, but that's up to you. I've posted the full texts of each file at the very end of this article for you.
Full Files[]
config\recipes.xml[]
<configs>
<append xpath="/recipes">
<recipe name="houseFrontDoor1_v1" count="1" craft_time="10" craft_area="workbench" tags="workbenchCrafting">
<ingredient name="resourceWood" count="6"/>
<ingredient name="resourceScrapBrass" count="2"/>
<ingredient name="resourceDoorKnob" count="1"/>
</recipe>
<recipe name="houseFrontDoor2_v1" count="1" craft_time="10" craft_area="workbench" tags="workbenchCrafting">
<ingredient name="resourceWood" count="6"/>
<ingredient name="resourceScrapBrass" count="2"/>
<ingredient name="resourceDoorKnob" count="1"/>
</recipe>
</append>
</configs>
config\Localization.txt[]
Key,Source,Context,Changes,English,French,German,Klingon,Spanish houseFrontDoor1_v1,blocks,Door,,Front Door,,,, houseFrontDoor2_v1,blocks,Door,,Front Door,,,,
config\blocks.xml[]
<configs> <setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="MaxDamage">250</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="FuelValue">200</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="CustomIcon">houseFrontDoor1_v1</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="TakeDelay">10</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="Group">Building,advBuilding</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="EconomicValue">10</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor1_v1']" name="EconomicBundleSize">10</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="MaxDamage">250</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="FuelValue">200</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="CustomIcon">houseFrontDoor1_v1</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="TakeDelay">10</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="Group">Building,advBuilding</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="EconomicValue">10</setattribute> <setattribute xpath="/blocks/block[@name='houseFrontDoor2_v1']" name="EconomicBundleSize">10</setattribute> </configs>
ModInfo.xml:[]
<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<Name value="yourUniqueIdentifier" />
<DisplayName value="My new mod name" />
<Version value="0.0.0.0" />
<Description value="Your mods description goes here" />
<Author value="xMisterDan" />
<Website value="" />
</xml>
UI Modlets[]
The following mods can be useful to you when creating modlets to modify the game UI. Once installed open the client console (F1) and enter the following command `quartz uiatlas`. You will need to run your game with EAC off to enable use of this mod.
A menu should appear that provides a seamless way to browse the games vanilla icons. Here is an example of its usage that adds a challenge symbol to the left of the compass HUD.
<config>
<insertAfter xpath="/windows/window[@name='windowCompass']/sprite[3]"
<sprite pos="-105,-8", size="24,24" sprite="ui_game_symbol_challenge_category2" color="255,255,255,255"></sprite>
</insertAfter>
</config>