Difference between revisions of "Modding"

From RimWorld Wiki
Jump to navigation Jump to search
(→‎I want my mod to...:: save data, as per https://ludeon.com/forums/index.php?topic=48046.0)
(42 intermediate revisions by 23 users not shown)
Line 1: Line 1:
'''Моды''' (сокращённо от модификации) это маленькие пакеты, что добавляют или изменяют геймплей в RimWorld. Они включают: визуальное изменение, дополнительное оружие, дополнительные инциденты, мебель, и изменение баланса игры.
+
<!--Top Nav Box-->
 +
{| align=center
 +
| {{Basics_Nav}}
 +
|}
 +
<hr>
  
Эта страница о том, как сделать моды. Для информации о том, как пользоваться модами, смотри [[Installing mods]].
+
{{See also|List of mods}}
 +
'''Mods''' (short for modifications) are small packages that add to or otherwise affect gameplay in RimWorld. They include art packs (for reskinning the game), more weapons, more incidents, furniture, and game-balancing mods. RimWorld mods may make use of XML and C#.
  
==Учебники по созданию модификаций==
+
This page is about making mods. For info about using mods, see [[Installing mods]].
Учебники по созданию модификаций доступны на странице [[Modding Tutorials]]. Если Вы не можете найти то, что Вам нужно, попробуйте посмотреть в [[Modding/Random Bits of Information|Random Bits of Information]] чтобы проверить, если информация, которую Вы ищете была найдена, но просто еще не была организована в правильной статье.
 
  
==Что Вы можете модифицировать==
+
==Mod-making tutorials==  
Вы можете модифицировать def-ы, код, изображения, и звуки.
+
Mod-making tutorials are available at the [[Modding Tutorials]] page. If you can't find what you need, you should try looking in [https://ludeon.com/forums/index.php?board=14.0 the forums help section on modding] to check if the information you're looking for has been asked previously, before starting your own thread.
  
* '''Def-ы''': XML файлы, содержащие списки определений для использования в игре. Есть много всего. Они определяют всё, навыки, рассказчиков, и многие другие типы данных. Найти их можно в YourModName/Defs. Подробнее об этом ниже.
+
===Mod-making Templates===
* '''Код''': Вы можете добавить .NET assemblies и игра загрузит их. Поместите свои DLL-ы в YourModName/Defs. Подробнее об этом ниже.
+
*[https://ludeon.com/forums/index.php?topic=39038.0 Mod Development Cookiecutter (automatically build your mod development environment)]
* '''Изображения''': Вы можете добавлять изображения.
 
* '''Звуки''': Вы можете добавлять звуковые файлы.
 
  
 +
==What you can mod==
 +
RimWorld does not limit what you can or can't do. The only limit is skills and motivation, or patience and willpower. You can mod everything, from defs, to code, images, and sounds. Some examples:
  
==Основы: Def-ы==
+
* '''Defs''': XML files containing lists of definitions for use by the game. There are a lot of these. They define every thing, skills, storyteller, and many other types of data. Find them in YourModName/Defs. More about this later.
Самый основной вид RimWorld моддинга производится путем редактирования '''def-ов'''.
+
* '''Code''': You can add .NET assemblies and the game will load them. Place your DLLs in YourModName/Assemblies. There is no API for RimWorld modding,  you can make full use of RimWorld's functions. You also have the full power of the .NET Framework 3.5 available. More about this later.
 +
* '''Images''': You can add images.
 +
* '''Sounds''': You can add sound files.
 +
* '''Patches''': Using xpath, you can edit Defs with pinpoint precision to change only the values you need to change while staying as compatible as possible with other mods.
 +
* '''Jobs''':  A useful link here https://github.com/Mehni/ExampleJob/wiki - covers JobGivers WorkGivers and Toils
 +
** Higher level, explanation on how pawns think:  https://github.com/roxxploxx/RimWorldModGuide/wiki/SHORTTUTORIAL%3A-How-Pawns-Think
  
Определения, каждое определение - часть игры. Различные виды определений можно разделить на:
+
==The basics: Defs==
Звуки
+
The most basic kind of RimWorld modding is done by editing '''Defs'''.
Оружие
 
Строения
 
Растения
 
Животные
 
Что-либо ещё (что будет определено)
 
  
Когда игра запускается, она собирает все определения в пулы. Потом полу-случайно берёт из них (из этих пулов) при различных обстоятельствах. Это будет случайным образом вооружать определённым оружием нового вражеского наёмника. Или случайно создавать животного на краю карты. Моддинг игры означает добавление Ваших определений для этих пулов и наблюдая за игрой использовать их таким образом.
+
Definitions each define some piece of the game. Different kinds of definitions can define:
  
Определения организованы в пакеты. Каждый пакет сохраняется в виде отдельного XML-файла.
+
* '''Weapons'''
 +
* '''Buildings'''
 +
* '''Plants'''
 +
* '''Animals'''
 +
* '''Sound'''
 +
* '''Research'''
 +
* '''Biomes'''
 +
* '''Much much more'''
  
Группы пакетов организованы в моды. Мод это единица взаимосвязанной функциональности и содержания. Это может быть пакет новых видов оружия, новое животное, или в общей сложности преобразоване игры. Моды, как правило, содержат несколько пакетов различных типов, а также наполнение, например, изображеня и звуки.
+
When the game runs, it collects all the definitions into a database. It then draws from these pools in when appropriate. It will randomly draw guns of a certain category to arm a new enemy mercenary. Or, it will randomly spawn an animal type on the edge of the map. Modding the game with Defs means adding your definitions to these pools and watching the game use them.
  
Базовая игра определяется в одном моде под названием Core.
+
A mod could be a pack of new weapons, a new animal, or a total conversion of the game. A mod will usually contain several Defs of various types, as well as content like images and sounds.
  
Игроки могут выбрать, какие из модов им активировать. В некоторых случаях, несколько модов могут быть активны одновременно. Вы можете использовать средневековый мод для замены основы игры, и добавить пачку оружия, созданного кем-то другим. Игра будет работать с содержанием средневекового мода, а также случайным образом появится оружие из пакета дополнительных вооружений.
+
The base game is defined in a single mod called Core.
 +
 
 +
Players can choose which mods to activate. Most players often have several mods active at once. You could use a medieval mod to replace the core mod, and add on a weapons pack created by someone else. The game will run with the medieval mod content, and also randomly spawn in weapons from the extra weapons pack.
  
 
==Mod file structure==
 
==Mod file structure==
Line 40: Line 53:
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="utf-8" ?>
 
<?xml version="1.0" encoding="utf-8" ?>
<SomeDefs>
+
<Defs>
 
   <SomeDef>
 
   <SomeDef>
 
       <defName>MyNewDefinitionOfContent</defName>
 
       <defName>MyNewDefinitionOfContent</defName>
 
       <!-- more tags will appear depending on what are you defining -->
 
       <!-- more tags will appear depending on what are you defining -->
 
   </SomeDef>
 
   </SomeDef>
</SomeDefs>
+
</Defs>
 
</source>
 
</source>
Remember, that the word '''Some''' must be replaced by the name of whatever are you defining. For thing it's '''&lt;ThingDef&gt;'''.
+
All rootnodes for Defs start with '''&lt;Defs&gt;'''. Remember, that the word '''Some''' must be replaced by the name of whatever are you defining. For thing it's '''&lt;ThingDef&gt;'''.
  
The RimWorld mods use the following directory structure:
+
The RimWorld mods use the following directory structure. Root folders have to follow the naming pattern (About, Assemblies, Defs, Sounds, Patches, Textures, Languages) for them to be read by RimWorld. Apart from the Languages Folder, subfolders can have any structure. For the sake of organisation, it is recommended to keep things categorised:
 
<pre>
 
<pre>
┌About  
+
┌About (Your mod MUST have an About folder containing an About.xml file. Case sensitive)
├╴About.xml (Contains info about the mod)
+
├─About.xml (Contains info about the mod)
├╴Preview.png (Image that appears above the mod info in game. Max width 600px.)
+
├─Preview.png (Image that appears above the mod info in game)
 
 
 
├Assemblies (If your mod uses any DLL files put them here)
 
├Assemblies (If your mod uses any DLL files put them here)
├╴MyMod.dll
+
├─MyMod.dll
 
 
 
├Defs (Contains xml definitions of the mod)
 
├Defs (Contains xml definitions of the mod)
 
├┬ThingDefs
 
├┬ThingDefs
│├╴Things.xml
+
│├─Things.xml
│└╴Buildings.xml
+
│└─Buildings.xml
 +
 
├┬ResearchProjectDefs
 
├┬ResearchProjectDefs
│└╴MyProjects.xml
+
│└─MyProjects.xml
│the folder name must be specific here. Look in Core mod to see what are other names supposed to be
 
 
 
├Sounds
 
 
 
 +
├┬Sounds (Put any sound files here. Universally supported formats are .ogg and .wav. .mp3 files are not guaranteed to work)
 +
├─MySound.wav
 +
|
 
├Source
 
├Source
├╴MyMod.cs (Optionally, put the source code of your mod here)
+
├─MyMod.cs (Optionally, put the source code of your mod here)
 +
 +
├Patches
 +
├─MyPatch.xml
 
 
├Strings
+
├Languages
 +
├┬English (Replace with the language name)
 +
│├┬Keyed
 +
││└─Keys.xml
 +
│├┬Strings
 +
││└┬Names
 +
││  └─PawnNames.xml
 +
│├┬DefInjected (NOTE: the folder (and subfolder) names must be specific here, and follow the XML structure of the mod)
 +
││└┬ThingDef
 +
││  └─Thing.xml
 +
│├─LanguageInfo.xml
 +
│└─LangIcon.png
 
 
 
├Textures (Put any image textures here, preferably in .png format.)
 
├Textures (Put any image textures here, preferably in .png format.)
└┬Things
+
├┬Things
├╴MyMod_ImageA.png
+
│├─MyMod_ImageA.png
└╴MyMod_ImageB.png
+
│└─MyMod_ImageB.png
 
</pre>
 
</pre>
  
Line 82: Line 111:
 
This is found in <code>MODNAME/About</code>
 
This is found in <code>MODNAME/About</code>
 
*The contents of About.xml are plain text. HTML Markup tags cause NullRef's.
 
*The contents of About.xml are plain text. HTML Markup tags cause NullRef's.
*You can have an image for your mod. Restrict the image width to 600 pixels
+
*You can have an image for your mod. Restrict the image size to 1 MB.
  
 
===Textures===
 
===Textures===
 
These are found in <code>MODNAME/Textures</code>
 
These are found in <code>MODNAME/Textures</code>
 
*You can have any path you want from this point on.
 
*You can have any path you want from this point on.
*When referencing textures in your mod, using <TexturePath>, have the complete path relative to your mod, including the filename (but not the file extension). Example for the RoyalBed Testmod: <code><TexturePath>Things/Building/RoyalBed</TexturePath></code>
+
*When referencing textures in your mod, using <graphicPath>, have the complete path relative to your mod, including the filename (but not the file extension). Example for the RoyalBed Testmod: <code><graphicPath>Things/Building/RoyalBed</graphicPath></code>
*You can randomize textures within a folder using a <textureFolderPath> pointing at a folder with multiple textures inside. Each Thing of the given def will have a random texture from the folder.
+
 
 +
For textures that have multiple faces, like animals and furniture which can be rotated; You can use the Graphic_Multi class. Immediately following your <graphicPath></graphicPath>. Your Path should point to the folder containing the different textures: Texturename_east (for both east- and west-facing), Texturename_south (front-facing), and Texturename_north (back-facing).
 +
<source lang="xml" >
 +
<graphicPath>Things/Buildings/RoyalCouch/RoyalCouch</graphicPath>
 +
<graphicClass>Graphic_Multi</graphicClass>
 +
</source>
 +
 
 +
Inside your folder:
 +
<pre>
 +
┌Textures
 +
└┬Things
 +
└┬Buildings
 +
  └┬RoyalCouch
 +
  ├╴RoyalCouch_east
 +
  ├╴RoyalCouch_south
 +
  └╴RoyalCouch_north
 +
</pre>
 +
 
 +
For plant textures that have multiple growth stages and/or utilize the Graphic_Random class, the different images for each stage must be in separate folders. These images within must also share the same filenames. For example, the [[corn plant]] has one immature form, and two different mature forms that appear at random once the plant is fully grown. Similarly to Graphic_Multi, when using the Graphic_Random class, you will always want to reference the folder containing the images rather than the images themselves. It should be noted that only harvestable plants are able to display an immature image.
 +
 
 +
An example of how retexturing a plant could work:
 +
 
 +
<source lang="xml" >
 +
<graphicPath>Things/Plants/CornPlant</graphicPath>
 +
<graphicClass>Graphic_Random</graphicClass>
 +
</source>
 +
 
 +
Your folder structure:
 +
<pre>
 +
┌Textures
 +
└┬Things
 +
└┬Plants
 +
  └┬CornPlant
 +
  ├╴CornPlant_A
 +
  └╴CornPlant_B
 +
  └┬CornPlant_Immature
 +
  ├╴CornPlant_A
 +
  └╴CornPlant_B
 +
</pre>
 +
 
 +
Even though there is only one image used for the immature corn plant, we must have two copies of it with the same filenames as the mature plant images in order to prevent broken textures in-game.
 +
If you wanted to add a leafless variant to a plant (such as the leafless trees in winter), another folder would be added.
 +
 
 +
<pre>
 +
┌Textures
 +
└┬Things
 +
└┬Plants
 +
  └┬CornPlant
 +
  ├╴CornPlant_A
 +
  └╴CornPlant_B
 +
  └┬CornPlant_Immature
 +
  ├╴CornPlant_A
 +
  └╴CornPlant_B
 +
  └┬CornPlant_Leafless
 +
  ├╴CornPlant_A
 +
  └╴CornPlant_B
 +
</pre>
  
===Interactive "things"===
+
===Interactive "Things"===
A thing is anything that exists in the game world. It includes resources, races (humanoid and animal), buildings, furniture, and many others.
+
A Thing is anything that exists in the game world. It includes resources, races (humanoid and animal), buildings, furniture, and many others.
  
 
These are defined in <code>MODNAME/Defs/ThingDefs</code>
 
These are defined in <code>MODNAME/Defs/ThingDefs</code>
If you make a new workbench, you'll need to define a recipe for it. This is a list, so you can have many new recipes listed.
+
If you make a new workbench, you'll need to define a recipe for it. This is a list, so you can have many new recipes listed. Note that new workbenches also need a WorkGiver tied to them, otherwise pawns will ignore your new bench.
  
 
The recipes themselves are defined in: <code>MODNAME/Defs/RecipeDefs</code>
 
The recipes themselves are defined in: <code>MODNAME/Defs/RecipeDefs</code>
Line 102: Line 187:
  
 
===Turrets===
 
===Turrets===
These are defined in two files in: <code>MODNAME/Defs/ThingDefs</code>
+
These are defined in two files in: <code>MODNAME/Defs/ThingDefs/Buildings_Big.xml</code> and <code>Weapons_Guns.xml</code> (Remember, these can be named anything)
Buildings_Big.xml and Weapons_Guns.xml (Remember, these can be named anything)
 
  
 
Buildings_Big.xml defines the structure of the turret itself. For example:
 
Buildings_Big.xml defines the structure of the turret itself. For example:
 
<source lang="xml" >
 
<source lang="xml" >
 
<building>
 
<building>
<turretGunDef>Gun_TurretImprovised</turretGunDef>
+
<turretGunDef>Gun_MiniTurret</turretGunDef>
<burstCooldownTicks>300</burstCooldownTicks>
+
<turretBurstCooldownTime>4.8</turretBurstCooldownTime>
 
</building>
 
</building>
 
</source>
 
</source>
Line 132: Line 216:
 
*The tilde key (` or ~) brings up the development console, which will report any errors or warnings it encounters when a mod loads or during gameplay. This is the quickest way to see what, if any, errors exist in your mod. (You don't need to turn on development mode for this.)
 
*The tilde key (` or ~) brings up the development console, which will report any errors or warnings it encounters when a mod loads or during gameplay. This is the quickest way to see what, if any, errors exist in your mod. (You don't need to turn on development mode for this.)
 
*Use development mode (found in the options menu) to help debug your mod, spawn items related to your mod, or fire incidents at will. (Or just mess around, if you'd like.)
 
*Use development mode (found in the options menu) to help debug your mod, spawn items related to your mod, or fire incidents at will. (Or just mess around, if you'd like.)
 +
 +
==I want to make a mod that can...:==
 +
'''Or, how do I make my mod do ''this''?'''
 +
 +
You can find links to tutorials on the [[Modding Tutorials]] page. There's also more tutorials about the basics there, so don't miss out on that.
 +
 +
* Save/Load information.  See a very useful guide at [https://spdskatr.github.io/RWModdingResources/saving-guide this page]
 +
** For saving settings for your mod, either use a class that extends ModSettings or use HugsLib.
 +
** For saving per-world data, make a [[Modding_Tutorials/GameComponent|Game Component]] and override ExposeData
 +
* Add a new value to a def
 +
** See [[Modding_Tutorials/ThingComp|ThingComp]]
 +
** Also helpful: [[Modding Tutorials/DefModExtension|DefModExtension]]s
  
 
== References ==
 
== References ==
*[http://ludeon.com/forums/index.php?topic=1681.0 Simple tutorial forum thread]
+
*[https://github.com/roxxploxx/RimWorldModGuide/wiki A good guide to assist people trying to mod RimWorld]
*[http://rimworldgame.com/publicArtSource/ThingGraphics.zip RimWorld core art source]
+
*[https://spdskatr.github.io/RWModdingResources/ A good collection of guides for RimWorld modders]
 +
*[https://ludeon.com/forums/index.php?topic=39038.0 Mod Development Cookiecutter (automatically build your mod development environment)]
 +
*[https://ludeon.com/forums/index.php?topic=2325.0 RimWorld core art source thread]
  
 +
== Notes ==
 +
*You can have as many mods as you like, however too many mods may affect performance.
 +
*If the game crashes due to a mod-related reason on startup, or mods conflict with each other, then the game will reset the mods.
 +
*Mods for previous versions may be usable, however most of the time they are not compatible.
  
 
[[Category:Modding]]
 
[[Category:Modding]]

Revision as of 15:06, 17 February 2019

Basics Menus Game Creation Gameplay Pawns Plants Resources Gear Mods
Basics Menu Controls User Interface Save File Modding Version history

Mods (short for modifications) are small packages that add to or otherwise affect gameplay in RimWorld. They include art packs (for reskinning the game), more weapons, more incidents, furniture, and game-balancing mods. RimWorld mods may make use of XML and C#.

This page is about making mods. For info about using mods, see Installing mods.

Mod-making tutorials

Mod-making tutorials are available at the Modding Tutorials page. If you can't find what you need, you should try looking in the forums help section on modding to check if the information you're looking for has been asked previously, before starting your own thread.

Mod-making Templates

What you can mod

RimWorld does not limit what you can or can't do. The only limit is skills and motivation, or patience and willpower. You can mod everything, from defs, to code, images, and sounds. Some examples:

  • Defs: XML files containing lists of definitions for use by the game. There are a lot of these. They define every thing, skills, storyteller, and many other types of data. Find them in YourModName/Defs. More about this later.
  • Code: You can add .NET assemblies and the game will load them. Place your DLLs in YourModName/Assemblies. There is no API for RimWorld modding, you can make full use of RimWorld's functions. You also have the full power of the .NET Framework 3.5 available. More about this later.
  • Images: You can add images.
  • Sounds: You can add sound files.
  • Patches: Using xpath, you can edit Defs with pinpoint precision to change only the values you need to change while staying as compatible as possible with other mods.
  • Jobs: A useful link here https://github.com/Mehni/ExampleJob/wiki - covers JobGivers WorkGivers and Toils

The basics: Defs

The most basic kind of RimWorld modding is done by editing Defs.

Definitions each define some piece of the game. Different kinds of definitions can define:

  • Weapons
  • Buildings
  • Plants
  • Animals
  • Sound
  • Research
  • Biomes
  • Much much more

When the game runs, it collects all the definitions into a database. It then draws from these pools in when appropriate. It will randomly draw guns of a certain category to arm a new enemy mercenary. Or, it will randomly spawn an animal type on the edge of the map. Modding the game with Defs means adding your definitions to these pools and watching the game use them.

A mod could be a pack of new weapons, a new animal, or a total conversion of the game. A mod will usually contain several Defs of various types, as well as content like images and sounds.

The base game is defined in a single mod called Core.

Players can choose which mods to activate. Most players often have several mods active at once. You could use a medieval mod to replace the core mod, and add on a weapons pack created by someone else. The game will run with the medieval mod content, and also randomly spawn in weapons from the extra weapons pack.

Mod file structure

For defining new game content, XML files are used. Here is an example of the format, that applies to most of the definitions:

<?xml version="1.0" encoding="utf-8" ?>
<Defs>
   <SomeDef>
      <defName>MyNewDefinitionOfContent</defName>
      <!-- more tags will appear depending on what are you defining -->
   </SomeDef>
</Defs>

All rootnodes for Defs start with <Defs>. Remember, that the word Some must be replaced by the name of whatever are you defining. For thing it's <ThingDef>.

The RimWorld mods use the following directory structure. Root folders have to follow the naming pattern (About, Assemblies, Defs, Sounds, Patches, Textures, Languages) for them to be read by RimWorld. Apart from the Languages Folder, subfolders can have any structure. For the sake of organisation, it is recommended to keep things categorised:

┌About (Your mod MUST have an About folder containing an About.xml file. Case sensitive)
├─About.xml (Contains info about the mod)
├─Preview.png (Image that appears above the mod info in game)
│
├Assemblies (If your mod uses any DLL files put them here)
├─MyMod.dll
│
├Defs (Contains xml definitions of the mod)
├┬ThingDefs
│├─Things.xml
│└─Buildings.xml
│
├┬ResearchProjectDefs
│└─MyProjects.xml
│
│
├┬Sounds (Put any sound files here. Universally supported formats are .ogg and .wav. .mp3 files are not guaranteed to work)
├─MySound.wav
|
├Source
├─MyMod.cs (Optionally, put the source code of your mod here)
│
├Patches
├─MyPatch.xml
│
├Languages
├┬English (Replace with the language name)
│├┬Keyed
││└─Keys.xml
│├┬Strings
││└┬Names
││  └─PawnNames.xml
│├┬DefInjected (NOTE: the folder (and subfolder) names must be specific here, and follow the XML structure of the mod)
││└┬ThingDef
││  └─Thing.xml
│├─LanguageInfo.xml
│└─LangIcon.png
│
├Textures (Put any image textures here, preferably in .png format.)
├┬Things
│├─MyMod_ImageA.png
│└─MyMod_ImageB.png

Mod info

This is found in MODNAME/About

  • The contents of About.xml are plain text. HTML Markup tags cause NullRef's.
  • You can have an image for your mod. Restrict the image size to 1 MB.

Textures

These are found in MODNAME/Textures

  • You can have any path you want from this point on.
  • When referencing textures in your mod, using <graphicPath>, have the complete path relative to your mod, including the filename (but not the file extension). Example for the RoyalBed Testmod: <graphicPath>Things/Building/RoyalBed</graphicPath>

For textures that have multiple faces, like animals and furniture which can be rotated; You can use the Graphic_Multi class. Immediately following your <graphicPath></graphicPath>. Your Path should point to the folder containing the different textures: Texturename_east (for both east- and west-facing), Texturename_south (front-facing), and Texturename_north (back-facing).

<graphicPath>Things/Buildings/RoyalCouch/RoyalCouch</graphicPath>
<graphicClass>Graphic_Multi</graphicClass>

Inside your folder:

┌Textures
└┬Things
 └┬Buildings
  └┬RoyalCouch
   ├╴RoyalCouch_east
   ├╴RoyalCouch_south
   └╴RoyalCouch_north

For plant textures that have multiple growth stages and/or utilize the Graphic_Random class, the different images for each stage must be in separate folders. These images within must also share the same filenames. For example, the corn plant has one immature form, and two different mature forms that appear at random once the plant is fully grown. Similarly to Graphic_Multi, when using the Graphic_Random class, you will always want to reference the folder containing the images rather than the images themselves. It should be noted that only harvestable plants are able to display an immature image.

An example of how retexturing a plant could work:

<graphicPath>Things/Plants/CornPlant</graphicPath>
<graphicClass>Graphic_Random</graphicClass>

Your folder structure:

┌Textures
└┬Things
 └┬Plants
  └┬CornPlant
   ├╴CornPlant_A
   └╴CornPlant_B
  └┬CornPlant_Immature
   ├╴CornPlant_A
   └╴CornPlant_B

Even though there is only one image used for the immature corn plant, we must have two copies of it with the same filenames as the mature plant images in order to prevent broken textures in-game. If you wanted to add a leafless variant to a plant (such as the leafless trees in winter), another folder would be added.

┌Textures
└┬Things
 └┬Plants
  └┬CornPlant
   ├╴CornPlant_A
   └╴CornPlant_B
  └┬CornPlant_Immature
   ├╴CornPlant_A
   └╴CornPlant_B
  └┬CornPlant_Leafless
   ├╴CornPlant_A
   └╴CornPlant_B

Interactive "Things"

A Thing is anything that exists in the game world. It includes resources, races (humanoid and animal), buildings, furniture, and many others.

These are defined in MODNAME/Defs/ThingDefs If you make a new workbench, you'll need to define a recipe for it. This is a list, so you can have many new recipes listed. Note that new workbenches also need a WorkGiver tied to them, otherwise pawns will ignore your new bench.

The recipes themselves are defined in: MODNAME/Defs/RecipeDefs In here you can define what ingredients/resources are required, what can be used, and what the default recipe is.

Any new resources will need to be defined in: MODNAME/Defs/ThingDefs

Turrets

These are defined in two files in: MODNAME/Defs/ThingDefs/Buildings_Big.xml and Weapons_Guns.xml (Remember, these can be named anything)

Buildings_Big.xml defines the structure of the turret itself. For example:

<building>
	<turretGunDef>Gun_MiniTurret</turretGunDef>
	<turretBurstCooldownTime>4.8</turretBurstCooldownTime>
</building>

Weapons_Gun.xml defines the weapon the turret uses. Anything can be used as a weapon for turrets, including grenades.

Resources

These are defined in: MODNAME/Defs/ThingDefs/Resources.xml

Research projects

These are found in: MODNAME/Defs/ResearchProjectDefs

You can have research trees as well, where additional research projects get unlocked as you move through. This is how to add prerequisites:

<prerequisites>
	<li>-this is the <defName> of the prerequisite-</li>
</prerequisites>

Because it's a list, you can have multiple prerequisites for a research project.

Advice

  • The tilde key (` or ~) brings up the development console, which will report any errors or warnings it encounters when a mod loads or during gameplay. This is the quickest way to see what, if any, errors exist in your mod. (You don't need to turn on development mode for this.)
  • Use development mode (found in the options menu) to help debug your mod, spawn items related to your mod, or fire incidents at will. (Or just mess around, if you'd like.)

I want to make a mod that can...:

Or, how do I make my mod do this?

You can find links to tutorials on the Modding Tutorials page. There's also more tutorials about the basics there, so don't miss out on that.

  • Save/Load information. See a very useful guide at this page
    • For saving settings for your mod, either use a class that extends ModSettings or use HugsLib.
    • For saving per-world data, make a Game Component and override ExposeData
  • Add a new value to a def

References

Notes

  • You can have as many mods as you like, however too many mods may affect performance.
  • If the game crashes due to a mod-related reason on startup, or mods conflict with each other, then the game will reset the mods.
  • Mods for previous versions may be usable, however most of the time they are not compatible.