Editing Modding Tutorials/Getting Started

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:
#REDIRECT [[Modding Tutorials/First Steps]]
+
{{BackToTutorials}}
 +
 
 +
'''NOTE: This series of tutorials is out of date, and the products will not function in alphas 12 and beyond. While it still may be a helpful exercise, xml structure of Defs have changed dramatically. '''
 +
 
 +
In this tutorial, we’re going to make a simple mod that adds a simple, useless block onto the game.
 +
 
 +
== Prerequisites ==
 +
 
 +
First, we’ll be working with XML files, so a program like [http://download.tuxfamily.org/notepadplus/ Notepad++] or Microsoft’s [http://xmlnotepad.codeplex.com/ XML Notepad] will definitely be better than just Notepad.
 +
 
 +
== Setup Directory Structure ==
 +
 
 +
Create the following directory structure in the RimWorld's Mods directory.
 +
 
 +
  SimpleBlock/
 +
    About/
 +
      About.xml
 +
      Preview.png
 +
    Defs/
 +
      ThingDefs/
 +
        Building_Structure_SimpleBlock.xml
 +
    Textures/
 +
      Things/
 +
        Building/
 +
          SimpleBlock_Atlas.png
 +
          SimpleBlock_Blueprint.png
 +
          SimpleBlock_MenuIcon.png
 +
     
 +
=== Rimworld's Mod's Directory ===
 +
 
 +
====Mac====
 +
Right click the RimWorld application and <code>Show Package Contents</code>, you should see a <code>Mods</code> directory.
 +
Place your SimpleBlock directory inside of the <code>Mods</code> directory
 +
 
 +
== Defining our SimpleBlock ==
 +
 
 +
Let's add the following code to our <code>Buildings_Structure_SimpleBlock.xml</code> file.
 +
 
 +
=== Barebones file ===
 +
Lets setup the basic structure of our SimpleBlock.
 +
 
 +
  <source lang="xml"><?xml version="1.0" encoding="utf-8"?></source>
 +
  <Buildings>
 +
    <ThingDef Name="BuildingBase" Abstract="True">
 +
    </ThingDef>
 +
    <ThingDef ParentName="BuildingBase">
 +
    </ThingDef>
 +
  </Buildings>
 +
 
 +
 
 +
=== Defining Building base ===
 +
 
 +
Since all of the buildings in this XML file will have the following properties, we’ll make an abstract ThingDef with the name <code>BuildingBase</code>, so your file should look like this:
 +
 
 +
  <?xml version="1.0" encoding="utf-8"?>
 +
  <Buildings>
 +
    <ThingDef Name="BuildingBase" Abstract="True">
 +
      <category>Building</category>
 +
      <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
 +
      <selectable>true</selectable>
 +
      <drawerType>MapMeshAndRealTime</drawerType>
 +
      <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
 +
      <repairEffect>Repair</repairEffect>
 +
      <filthLeaving>BuildingRubble</filthLeaving>
 +
    </ThingDef>
 +
    <ThingDef ParentName="BuildingBase">
 +
    </ThingDef>
 +
  </Buildings>
 +
 
 +
 
 +
This doesn’t provide enough information to define a whole in-game building (hence the abstract) so we’ll make another object. This one will provide all of the necessary properties. We can break this one up even further, but since we’re just going to make a single object it doesn’t really matter.
 +
 
 +
=== Creating the simple object ===
 +
 
 +
Now we will define our SimpleBlock.
 +
 
 +
  <?xml version="1.0" encoding="utf-8"?>
 +
  <Buildings>
 +
    <ThingDef Name="BuildingBase" Abstract="True">
 +
      <category>Building</category>
 +
      <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
 +
      <selectable>true</selectable>
 +
      <drawerType>MapMeshAndRealTime</drawerType>
 +
      <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
 +
      <repairEffect>Repair</repairEffect>
 +
      <filthLeaving>BuildingRubble</filthLeaving>
 +
    </ThingDef>
 +
    <ThingDef ParentName="BuildingBase">
 +
 
 +
      <designationCategory>Structure</designationCategory>
 +
 +
      <defName>SimpleBlock</defName>
 +
      <label>Simple block</label>
 +
      <description>An ugly thing.</description>
 +
 
 +
      <graphicPath>Things/Building/SimpleBlock_Atlas</graphicPath>
 +
      <blueprintgraphicPath>Things/Building/SimpleBlock_BluePrint</blueprintgraphicPath>
 +
      <graphicClass>Graphic_Single</graphicClass>
 +
      <uiIconPath>Things/Building/SimpleBlock_MenuIcon</uiIconPath>
 +
 
 +
      <statBases>
 +
        <MaxHealth>450</MaxHealth>
 +
        <Beauty>2</Beauty>
 +
        <WorkToMake>100</WorkToMake>
 +
        <Flammability>0</Flammability>
 +
      </statBases>
 +
 
 +
      <size>(1,1)</size>
 +
      <costList>
 +
        <Steel>7</Steel>
 +
      </costList>
 +
 
 +
      <filthLeaving>BuildingRubble</filthLeaving>
 +
 
 +
      <eType>BuildingComplex</eType>
 +
      <thingClass>Building</thingClass>
 +
      <altitudeLayer>BuildingTall</altitudeLayer>
 +
      <passability>Impassable</passability>
 +
      <castEdgeShadows>true</castEdgeShadows>
 +
      <fillPercent>1</fillPercent>
 +
      <placingDraggableDimensions>0</placingDraggableDimensions>
 +
      <tickerType>Never</tickerType>
 +
      <rotatable>true</rotatable>
 +
      <neverMultiSelect>true</neverMultiSelect>
 +
      <holdsRoof>false</holdsRoof>
 +
      <staticSunShadowHeight>0.5</staticSunShadowHeight>
 +
      <blockLight>true</blockLight>
 +
    </ThingDef>
 +
  </Buildings>
 +
 
 +
== Finishing touches ==
 +
 
 +
We need to identify our mod so that RimWorld can recognize it. Edit the <code>About.xml</code> and place the following code inside of it:
 +
 
 +
<source lang="xml"><?xml version="1.0" encoding="utf-8"?>
 +
<ModMetaData>
 +
  <name>Simple Block</name>
 +
  <author>Your name here!</author>
 +
  <url>about:blank</url>
 +
  <targetVersion>Alpha 9</targetVersion>
 +
  <description>A very simple block for a tutorial.</description>
 +
</ModMetaData></source>
 +
 
 +
If you’d like, you can also add an image called <code>Preview</code>. You can make that image any size.
 +
 
 +
== Testing ==
 +
 
 +
Let’s test our new mod! Fire up RimWorld, making sure to turn on <code>Development mode</code> in the options menu. Turn on the mod, and press the tilde key (~) to check for any errors thrown on runtime. That’s right, no errors! Enjoy your first mod!
 +
 
 +
Remember, if you update your mod files between game sessions, you will need to re-open the mods screen when you run the game, otherwise your changes will not be properly processed.
 +
 
 +
==Download==
 +
 
 +
From now on, we'll be using GitHub to store finished tutorials. Each branch in the Git repository will contain an up-to-date browsable and downloadable archive for a specific tutorial. In future and more complex tutorials, there might be individual commits for each step in the tutorial.
 +
 
 +
You can take a look at the branch for this tutorial [https://github.com/oldmud0/rwmd/tree/tutorial1 here], and you can download a zip archive [https://github.com/oldmud0/rwmd/archive/tutorial1.zip here].
 +
 
 +
== Conclusion ==
 +
 
 +
You now know how to:
 +
* make a simple, single-file mod
 +
* manage XML files along with their resources
 +
* create a building that covers a single space
 +
* finalize a mod for consumption
 +
* learn how to follow instructions
 +
 
 +
 
 +
Next, we’ll learn how to make various types of items.
 +
 
 +
[[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)