Editing Modding Tutorials/Getting started with mods

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
 
{{BackToTutorials}}
 
{{BackToTutorials}}
  
This page is a tutorial on how to create a RimWorld mod, it will step you through the process of creating a mod from scratch. From basic file structure to writing code for your mod. This tutorial is aimed at people who have never created a mod before and are looking to get started. And is meant to be an updated guide for the old tutorials on the wiki. If you're still facing issues after using this tutorial, head over to the [https://discord.gg/rimworld/ RimWorld Discord server]. In the server, there's a Modding Resources section where you might find help if you're stuck during mod creation.
+
This page is a tutorial on how to create a RimWorld mod, it will step you through the process of creating a mod from scratch. From basic file structure to writing code for your mod. This tutorial is aimed at people who have never created a mod before and are looking to get started. And is meant to be an updated guide for the old tutorials on the wiki. If you still have problems after following this tutorial, visit https://discord.gg/rimworld ; There is a category Modding resources, where you possibly get some help if you are stuck with your first mod.  
  
 
=Introduction=
 
=Introduction=
Line 21: Line 21:
 
* [https://steamcommunity.com/sharedfiles/filedetails/?id=1847679158 RimPy] (This is a Mod manager that will make it easier to test your mod)
 
* [https://steamcommunity.com/sharedfiles/filedetails/?id=1847679158 RimPy] (This is a Mod manager that will make it easier to test your mod)
 
* [https://git-scm.com/ Git] can be scary at first, but it is a very useful tool. And can be used to keep track of changes to your mod. (Optional but highly recommended)
 
* [https://git-scm.com/ Git] can be scary at first, but it is a very useful tool. And can be used to keep track of changes to your mod. (Optional but highly recommended)
* GitHub account; Using GitHub repositories for handling small mod changes and fixing bugs helps mod creators easily keep track of their modifications.
+
* GitHub account; you can use GitHub easily to make smaller changes/fixing smaller bugs in your mods, instead of releasing (bigger) updates on Steam workshop.
  
 
==Code Editor==
 
==Code Editor==
Line 35: Line 35:
 
=Making the folder structure=
 
=Making the folder structure=
 
'''''There are mod templates available for quick setup, however it is recommended to create the folder structure manually at least once to get a better understanding of how mods work.'''''
 
'''''There are mod templates available for quick setup, however it is recommended to create the folder structure manually at least once to get a better understanding of how mods work.'''''
To start making a mod, we need to create a folder for the mod. This folder will contain all the files and folders that make up the mod.<br>
+
To start making a mod, we need to create a folder for the mod. This folder will contain all the files and folders that make up the mod. To keep things organized, we will create a folder in RimWorld's mod local folder. This is located at: <br>
'''Note:''' Avoid putting your local mod in the Steam mods' folder, as it's meant for published workshop mods. Many beginners make this mistake and then wonder why their mod isn't visible in their test game.
 
To keep things organized, we will create a folder in RimWorld's mod local folder, which is located at:  
 
 
<pre>(RimWorldInstallFolder)/Mods/</pre>
 
<pre>(RimWorldInstallFolder)/Mods/</pre>
 +
'''''Note: it is not recommended to put your mod in the steam mods' folder''''' since it is a local mod and not yet published on the Steam workshop.
  
 
==Making an "about” file. ==
 
==Making an "about” file. ==
 
Now let's make an About folder inside the mod folder. This folder will contain information about the mod and the mods preview image.
 
Now let's make an About folder inside the mod folder. This folder will contain information about the mod and the mods preview image.
Inside the About folder, we will create a file called About.xml. This file will contain information about the mod. Inside the file, we will add the following code:
+
Inside the About folder, we will create a file called About.xml. This file will contain information about the mod. Inside the file, we will add the following code: <br>
 +
 
 
<pre>
 
<pre>
<?xml version="1.0" encoding="UTF-8"?> <!-- Comments in XML look like this -->
+
<?xml version="1.0" encoding="UTF-8"?> <! -- Comments in XML look like this-->
 
</pre>
 
</pre>
This is the first line of every XML file. It tells the computer that this is an XML file and what encoding to use. Get used by putting this line in every XML file you make)<br>
+
<br>
now we will add the following code to the file:
+
This is the first line of every XML file. It tells the computer that this is an XML file and what encoding to use. (Get used to seeing this line in every XML file you make) <br/>
 +
now we will add the following code to the file: <br>
 
<pre>
 
<pre>
 
<ModMetaData>
 
<ModMetaData>
Line 59: Line 60:
 
</ModMetaData> <!-- be sure to close all tags you open -->
 
</ModMetaData> <!-- be sure to close all tags you open -->
 
</pre>
 
</pre>
 +
<br>
 
'''''XML is picky about spacing, formatting, and Capitalization. If you get an error when loading your mod, it is most likely because of a typo or missing <tag> or forgot the closing </tag>.'''''
 
'''''XML is picky about spacing, formatting, and Capitalization. If you get an error when loading your mod, it is most likely because of a typo or missing <tag> or forgot the closing </tag>.'''''
Now save the file and close it. '''Note: the name of the file must be exactly "About.xml"'''
+
<br> Now save the file and close it. <br>
 +
'''''Note: the name of the file must be exactly "About.xml"'''''
 
Open RimPy and sort by local mods. You should see your mod listed. If you click on it, you should see the information you have entered in the About.xml file. <br>
 
Open RimPy and sort by local mods. You should see your mod listed. If you click on it, you should see the information you have entered in the About.xml file. <br>
'''''When adding a preview image to your mod you must name the image "Preview.png" and place it in the About folder, the image resolution should be 512×512 pixels and the size must be under 2mb'''''
+
 
 +
'''''When adding a preview image to your mod you must name the image "Preview.png" and place it in the About folder the image should be 512×512 pixels and must be under 1mb'''''
  
 
==Creating the other folder==
 
==Creating the other folder==
Now let's make a Def's folder inside the mod folder. This folder will contain all the XML files that define the content the mod will add.<br>
+
Now let's make a Def's folder inside the mod folder. This folder will contain all the XML files that define the content the mod will add. <br>
Start by creating a folder called "Defs" inside the mod folder, inside the Defs folder create a file called "ThingDefs.xml" <br>
+
start by creating a folder called "Defs" inside the mod folder, inside the Defs folder create a file called "ThingDefs.xml" <br>
let's also create a folder called "Textures" inside the mod folder. this folder will contain all the images that will be used in the mod.<br>
+
In the root of the mod folder create a folder called "Patches". this folder will contain XML files that will be used to patch existing content in the game. Inside the Patches folder create a file called "ThingDefs_Patch.xml" <br>
Your mod folder should now look like this:  
+
let's also create a folder called "Textures" inside the mod folder. this folder will contain all the images that will be used in the mod. <br>
 +
 
 +
Your mod folder should now look like this: <br>
 
<pre>
 
<pre>
 
ModName
 
ModName
Line 76: Line 82:
 
     Defs
 
     Defs
 
         ThingDefs.xml
 
         ThingDefs.xml
 +
    Patches
 +
        ThingDefs_Patch.xml
 
     Textures
 
     Textures
 
</pre>
 
</pre>
Line 83: Line 91:
  
 
==Adding a new item==
 
==Adding a new item==
Remember, this is the first line of every XML file.
+
Let's start by adding a new item to the game, open the "ThingDefs.xml" file and add the following code: <br>
<pre>
+
 
 +
<pre>  
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
</pre>
 
</pre>
Let's start by adding a new item to the game, open the “ThingDefs.xml” file and add the following code:
+
Remember this is the first line of every XML file.
 +
<br/>
 +
 
 
<pre>
 
<pre>
 
<Defs>
 
<Defs>
Line 106: Line 117:
 
</Defs>
 
</Defs>
 
</pre>
 
</pre>
Now save the file and close it. In RimPy enable the mod and start the game. When in-game, go to settings and enable [https://rimworldwiki.com/wiki/Development_mode development mode]. On the main menu, you'll see a new button named “Dev quick test.” Clicking it starts a new game on a test map. After the game loads, open the Debug actions menu and click on the “Spawn Thing” button. In the “Spawn Thing” menu, type in the def name of the item you just added. Click on the item, then click anywhere on the map to spawn it. Congratulations, you have just added your first item to the game. [[File:empty_item.png|200px|thumb|right|You have now added a new item to the game.]]
+
Now save the file and close it. In RimPy enable the mod and start the game. In Settings under general enable Development Mode.
 +
Now on the main menu, there should be a new button called "Dev quick test", This will start a new game on a test map. Once the game has loaded open the Debug menu, in the Debug menu click on the "Spawn Thing" button. In the "Spawn Thing" menu type in the def name of the item you just added. Click on the item then click anywhere on the map to spawn it. <br> Congratulations you have just added your first item to the game. [[File:empty_item.png|200px|thumb|right|You have now added a new item to the game.]]
  
 
==Adding a texture to the item==
 
==Adding a texture to the item==
While we have added an item to the game currently, it has no texture and shows a pink box, this means it has no texture yet. We can fix this by adding a corresponding texture to the item. We do this by adding a Texture folder which contains the corresponding ItemName.PNG. Take the example texture from the RimWorld wiki (this means the image will be the correct size and format). The "Animal Gear Base" mod [https://steamcommunity.com/workshop/filedetails/?id=1541438907/ Animal Gear] has folders meant to help you create a mod for animal apparel. In these folders, you'll find an ItemName.png file which can act as placeholder image.<br>
+
While we have added an item to the game currently, it has no texture and shows a pink box, this means it has no texture yet. We can fix this when we add a corresponding texture to the item. We do this by adding a Texture folder which contains the corresponding ItemName.PNG. Take the example texture from the RimWorld wiki (this means the image will be the correct size and format). The mod Animal gear base [https://steamcommunity.com/workshop/filedetails/?id=1541438907/ Animal Gear Mod] has also an ItemName.png Placeholder image to use as an example. And contains some Helper folders if you want to make an add-on for the animal gear framework, which contains nice apparel for dogs for example. <br>
Here's what your texture folder should look like:
+
Here's what your texture folder should look like: <br>
 
<pre>
 
<pre>
 
Textures
 
Textures
Line 118: Line 130:
 
                 Resource.png
 
                 Resource.png
 
</pre>
 
</pre>
It is best to organize your textures into folders that match the folder structure of the game. After you have added your texture to the mod folder, open the "ThingDefs.xml" file and add the following code to your items ThingDef:
+
It is best to organize your textures into folders that match the folder structure of the game. after you have added your texture to the mod folder open the "ThingDefs.xml" file and add the following code to your items ThingDef:
 +
<br>
 
<pre>
 
<pre>
 
<graphicData>
 
<graphicData>
Line 127: Line 140:
 
''''''Note how you don't add the file extension to the texture path.'''''' <br>
 
''''''Note how you don't add the file extension to the texture path.'''''' <br>
 
Now that looks much better! [[File:Adding_Textures.png|200px|thumb|right|Look at that lovely item]]
 
Now that looks much better! [[File:Adding_Textures.png|200px|thumb|right|Look at that lovely item]]
 
+
If you consider yourself an artist, you can make your own textures. Vector-based programs are preferred, but make sure your textures are saved as PNG files and have a maximum storage size of 1 gigabyte.
==Important when adding textures==
+
If you want to include the Photoshop/Gimp/Krita original files, you can do so, but be aware that they will make your mod bigger in size which will be unnecessary. Also, when people are using RimPy or RimSort (with todds) they can convert your textures, so dds files will be generated. Using mods like Graphic settings+ or Performance Fish, the game can use these DDS files, and it will improve your loading time and performance in your game. <br>
* You have the option to use either vector-based programs or grid-based programs.
 
* Textures must be exported as PNG files in order for them to be usable within the game.
 
* PNG files should not exceed 1 GB in size and can be up to 2 MB per texture.<br>
 
For optimal performance and visual quality, consider keeping PNG texture files at a moderate resolution that suits your mod's style. Aim for a balance between 2 MB and 10 MB per texture, as larger files might affect loading times.
 
  
 
==Adding more complex properties==
 
==Adding more complex properties==
Now that we have added a new item to the game, we can add some more features to it. to start we will make the item rot. open the "ThingDefs.xml" file and add the following code to your items ThingDef:
+
Now that we have added a new item to the game, we can add some more features to it. to start we will make the item rot. open the "ThingDefs.xml" file and add the following code to your items ThingDef: <br>
 
<pre>
 
<pre>
 
<comps>
 
<comps>
    <tickerType>Rare</tickerType>
+
     <li Class="CompProperties_Rottable"> <!-- This means that the comp can be rotated -->
     <li Class="CompProperties_Rottable"> <!-- This tells the game that the item can rot -->
 
 
         <daysToRotStart>2</daysToRotStart> <!-- This is the number of days it takes for the item to start rotting -->
 
         <daysToRotStart>2</daysToRotStart> <!-- This is the number of days it takes for the item to start rotting -->
 
         <daysToDessicated>3</daysToDessicated> <!-- This is the number of days it takes for the item to start desiccating -->
 
         <daysToDessicated>3</daysToDessicated> <!-- This is the number of days it takes for the item to start desiccating -->
Line 145: Line 153:
 
</comps>
 
</comps>
 
</pre>
 
</pre>
The best way to learn how to add more features to your items is to look at the existing items in the game. You can find the XML files for the existing items in the RimWorld install folder located at:  
+
the best way to learn how to add more features to your items is to look at the existing items in the game. You can find the XML files for the existing items in the RimWorld install folder located at: <br>
 
<pre>
 
<pre>
 
steamapps/common/RimWorld/Data/Core (Or any DLC you have) or Games/RimWorld/Data/Core
 
steamapps/common/RimWorld/Data/Core (Or any DLC you have) or Games/RimWorld/Data/Core
 
</pre>
 
</pre>
 +
<br>
 
You can for example open the RimWorld/Data/Core/Defs folder in your Code editor to see all the items, to understand its structure. It will be easier to navigate through all the folders.
 
You can for example open the RimWorld/Data/Core/Defs folder in your Code editor to see all the items, to understand its structure. It will be easier to navigate through all the folders.
Also, here you can find a Cheatsheet which you can use for Git commands [https://phoenixnap.com/kb/git-commands-cheat-sheet#ftoc-heading-10/ Cheatsheet]
+
Also, here you can find a Cheatsheet which you can use for Git (commands) [https://phoenixnap.com/kb/git-commands-cheat-sheet#ftoc-heading-10/ Cheatsheet]
  
 
=GitHub files=
 
=GitHub files=
 
* All the files made in this tutorial can be found [https://github.com/Zeta-of-the-rim/RimWorld-Mod-Tutorials here] on GitHub. this allows you to download the files and use them as a reference when making your own mods.
 
* All the files made in this tutorial can be found [https://github.com/Zeta-of-the-rim/RimWorld-Mod-Tutorials here] on GitHub. this allows you to download the files and use them as a reference when making your own mods.
 +
* Bradson made a Mod template on GitHub, you can find it here: [https://github.com/bbradson/ModTemplate/ Mod template]
 
GitHub is a great tool for sharing code and is especially useful when you are ready to start programming in C#.
 
GitHub is a great tool for sharing code and is especially useful when you are ready to start programming in C#.
  
 
=Next steps=
 
=Next steps=
After completing this tutorial, you'll have a basic understanding of modding in RimWorld. Now, you can begin adding more features to your mod, starting with recipes, weapons, and traits.[[Modding_Tutorials/Xml_Adding_Weapons_Traits_Research|Next Tutorial]]
+
After you have completed this tutorial, you should have a basic understanding of how to make a mod for RimWorld. now you can start adding more features to your mod. The next step is adding a recipe, weapon, and trait to the mod. [[Modding_Tutorials/Xml_Adding_Weapons_Traits_Research|Next Tutorial]]
  
 
[[Category:Modding tutorials]]
 
[[Category:Modding tutorials]]

Please note that all contributions to RimWorld Wiki are considered to be released under the CC BY-SA 3.0 (see RimWorld Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: