Difference between revisions of "Modding Tutorials/Mod folder structure"

From RimWorld Wiki
Jump to navigation Jump to search
(Finished page)
(Added next up, removed see also)
Line 192: Line 192:
 
   The # after a folder stands for a folder depth of >= 0.
 
   The # after a folder stands for a folder depth of >= 0.
  
=See also=
+
=Next up=
* [[Modding Tutorials/Folder structure]]
+
* [[Modding Tutorials/Recommended software]]
  
 
[[Category:Modding tutorials]]
 
[[Category:Modding tutorials]]

Revision as of 15:37, 12 July 2015

This tutorial introduces you to the mod folder structure and shows you a standard folder structure setup to help you start out.

Complete mod folder structure is a list of all folders you might find in your average mod directory. This includes /Core/.

What you'll learn

You'll learn the following mod structure:

 YourModName/
   About/
     About.xml
     Preview.png
   Assemblies/
     ProjectName.dll
   Defs/
     (..)
   Languages/
     English/
       Strings/
         NameBanks/
   Sounds/
   Source/
     ProjectName/
       ProjectName.sln
   Textures/

.. Along with a few tips on how to keep your mod folder structure readable and functional.

Standard mod folder structure

The About folder

Making a mod starts with you making a folder structure. Some mods need textures and sounds, while others are XML or even C# only.
Every mod does however require the following structure to show up in the mods list:

 YourModName/
   About/
     About.xml

Along with this vital information it's possible to add a preview image for your mod. This makes the structure as follows:

 YourModName/
   About/
     About.xml
     Preview.png

The size of the base game Preview.png is 400x61 pixels, but some mods use higher preview images. The image is centered in the mod's description, and can be of any size.

The Defs folders

If your mod adds new content, chances are you're going to use XML files. These files are going to be stored in the folder structure as follows:

 YourModName/
   Defs/
     BiomeDefs/
       Biomes.xml
     BodyDefs/
       Bodies.xml
     BodyPartDefs/
       BodyParts.xml
     (..)

The contents of a Def folder don't follow a clear naming convention, but the folder names are generally the same in every mod.
Using a non-standard name is going to make it harder for others to navigate your mod's folders, so it is advised to keep the folder names consistent with the base game.

Typically, the files inside these folders are named after their contents:

 Core/
   Defs/
     ThingDefs/
       Apparel_Hats.xml
       Apparel_Shield.xml
       (..)
       Weapons_Melee.xml
       Weapons_RangedNeolithic.xml

This makes it easier for people to navigate XML code. If your mod is going to add both apparel and weapons, or even both hats and shoes, you're best off separating the XML code in their respective files.
Some mod authors choose to make a separate file for each of their items. This makes it easier for others to remove only part of your mod and keep the rest of it, but with very large mods it makes it harder to navigate the folder.

The Textures and Sounds folders

If you're using Defs chances are you're creating a content mod. This type of mod is most likely very dull without its own custom graphics and sounds. Adding such content requires the following folders:

 YourModName/
   Textures/
   Sounds/

The contents of the Textures and Sounds folder usually aren't the same between mods. The base game sorts these files in various folders and subfolders, but in the end it's very hard to navigate them based on the folder names.
It's possible to categorize this content by item (submachinegun#1, pistol#3) or item type (guns, buildings), as an example. Whatever you do it's best to keep the structure consistent throughout both folders.

The Source and Assemblies folders

If you want to take a shot at C# modding, you want a Source and an Assemblies folder. You'll want to create the C# project inside your Source folder, and compile the class library into the Assemblies folder:

 YourModName/
   Assemblies/
     ProjectName.dll
   Source/
     SolutionName/
       ProjectName/
         ProjectName.sln
         (..)

Or:

 YourModName/
   Assemblies/
     ProjectName.dll
   Source/
     ProjectName/
       ProjectName.sln
       (..)

The structure of these folders is decided almost entirely by the author's editing software. Therefore the only things you have to set up are the following folders:

 YourModName/
   Assemblies/
   Source/

.. And then once you create a solution starting in ../YourModName/Source/ everything else will be sorted out by the software. People don't navigate these folders, they open ProjectName.sln to navigate it using their software of choice.

The Languages folder

Unless you're on a translation team, you're unlikely to need this folder a lot. If you want to randomly generate names using your own words, you will however have to use this folder:

 YourModName/
   Languages/
     English/
       Strings/
         NameBanks/

In this folder you put .txt files with a new word on every line. Using XML you will then be able to randomly pick one of the lines in the file.
In the average mod the rest of the folder is quite useless. You are unlikely to translate your mod into tens of different languages.

Complete mod folder structure

 */
   About/
     About.xml
     Preview.png-
   Assemblies/-
     *.dll+
   Defs/-
     *Defs/+
       *.xml+
   Languages/-
     */*
       DefInjected/-
         *Defs/+
           *.xml+
       Keyed/-
         *.xml+
       Strings/-
         NameBanks/
           *.txt+
       FriendlyName.txt-
       LangIcon.png
       LanguageInfo.xml
   Sounds/-
     */*#
       *.wav+
   Source/-
     */*#
       bin/
         Debug/
           *.**
       obj/
         Debug/
           *.**
       Properties/-
         AssemblyInfo.cs
       Source-DLLs/-
         Assembly-CSharp.dll
         UnityEngine.dll
       *.csproj
       *.OpenCover.Settings
       *.sln
       */*#
         *.cs+
   Textures/-
     */*#
       *.psd*
       *.psd.meta*
       *.png*
 Anything with a / at the end is a folder;
 Anything with a . in it is a file;
 The * in *.* and */ stands for any arbitrary string;
 The * after a file/folder stands for an occurence of >= 0;
 The + after a file/folder stands for an occurrence of > 0;
 The - after a file/folder stands for an occurrence of <= 1;
 The # after a folder stands for a folder depth of >= 0.

Next up