Modding Tutorials/Items
This page has been marked as a candidate for deletion. Reason: Obsolete - See talk page If you disagree with its deletion, please explain why in the Discussion page. Remember to check What Links Here and the Page History before deleting. |
In this tutorial, we'll make a simple item. This item will act as a resource that can be hauled around and consumed.
Prerequisites[edit]
You should have read the Getting Started tutorial, which gets you up to speed with how mods are structured in RimWorld. You should also have a good understanding of where files are located (such as About.xml
, def XML files, where you should put textures, and so on).
Making the folders[edit]
If you haven't already created a ThingDef folder as taught in the Getting Started tutorial, you will need to create a new folder in which will contain your new item xml. Inside your Defs
folder create a new subfolder called ThingDefs
. You're now done as far as creating folders go.
Creating the new resource item (Titanium example)[edit]
In this example, we'll be making a new resource called Titanium. This will be a resource in the game that can be used to make and build other things.
First of all we need to make it so the game will read this xml and let it know it's requesting new resources be added to the game. Start of by making your xml look like this.
<?xml version="1.0" encoding="utf-8" ?> <Resources> </Resources>
Now, we need to add a new abstract ThingDef which will be the base properties of the resource. Add this Between <Resources> and </Resources>
<ThingDef Name="ResourceBase" Abstract="True"> <defName>base_Resource</defName> <thingClass>ThingResource</thingClass> <label>Unspecified resource</label> <category>Item</category> <eType>Item</eType> <resourceCountPriority>Middle</resourceCountPriority> <useStandardHealth>true</useStandardHealth> <selectable>true</selectable> <maxHealth>100</maxHealth> <altitudeLayer>Item</altitudeLayer> <stackLimit>75</stackLimit> <purchasable>true</purchasable> <comps> <li><compClass>CompForbiddable</compClass></li> </comps> <beauty>Ugly</beauty> <alwaysHaulable>true</alwaysHaulable> <drawGUIOverlay>true</drawGUIOverlay> <rotatable>false</rotatable> <pathCost>15</pathCost> </ThingDef>
None of this changes, as we can override everything in the new resource def. Now add this under the new Abstract ThingDef but above </Resource> which should be at the bottom.
<ThingDef ParentName="ResourceBase"> <defName>Titanium</defName> <label>Titanium</label> <description>A rare strong and useful metal.</description> <texturePath>Things/Item/Resource/Titanium</texturePath> <interactSound>MetalDrop</interactSound> <basePrice>3</basePrice> <useStandardHealth>false</useStandardHealth> <storeCategories> <li>ResourcesRaw</li> </storeCategories> </ThingDef>
Hopefully, you’ll be able to understand what each property is once you read the page on ThingDef.
Testing[edit]
Let’s test our new mod! Fire up RimWorld, making sure to turn on Development mode
in the options menu. Open the mods menu and make sure your mod is ticked (For active), and then press the tilde key (~) to check for any errors thrown on runtime. That’s right, no errors! Now start a new game and activate God mode
, then attempt to spawn your resource into the game! In further tutorials we will teach you how to add uses to this resource aswell as add ways to obtain it.
Conclusion[edit]
You now know how to:
- make a simple resource
- know most of the thingDef's global attributes and their functions with the optional choices
Tutorial brought to you by Cala13er, If you have any questions about this tutorial. Message either Cala13er or Tynan on the forums.
Next we'll learn how to make a flooring!