Difference between revisions of "Modding Tutorials/Getting Started"

From RimWorld Wiki
Jump to navigation Jump to search
(Blanked out of date info and redirected the page to First Steps)
Tag: New redirect
 
(16 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<small>< [[Modding Tutorials]]</small>
+
#REDIRECT [[Modding Tutorials/First Steps]]
 
 
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.
 
 
 
== Making the folders ==
 
 
 
Create the following folder structure in RimWorld's Mods directory.
 
 
 
  SimpleBlock/
 
    About/
 
      About.yml
 
    Defs/
 
      ThingDefs/
 
        Building_Structure_SimpleBlock.xml
 
 
 
=== 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
 
 
 
== Creating the def’s XML file ==
 
 
 
Next, we’ll make the folder where we’ll put our def’s XML file. Inside this root folder, make a folder called <code>Defs</code>, and inside that folder, make another folder called <code>ThingDefs</code>. Enter <code>ThingDefs</code>. This is where we’ll be putting our XML file that defines our content.
 
 
 
Create an XML file. The easiest but slowest way is to open Notepad, press <code>Save As...</code>, browse to the <code>ThingDefs</code> folder, select <code>All files</code>, and then save the file as <code>Buildings_Structure_SimpleBlock.xml</code>. Now, open the file with your editor of choice.
 
 
 
=== Headers ===
 
 
 
All XML files we’ll be working with will need this header at the very top, so write it:
 
 
 
<source lang="xml"><?xml version="1.0" encoding="utf-8"?></source>
 
This basically tells the RimWorld engine’s XML reader that this file conforms to the XML 1.0 standard and that the file is encoded in UTF-8.
 
 
 
=== 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:
 
 
 
<source lang="xml"><?xml version="1.0" encoding="utf-8"?>
 
<Buildings>
 
 
 
<ThingDef Name="BuildingBase" Abstract="True">
 
<category>Building</category>
 
<soundBulletHit>BulletImpactMetal</soundBulletHit>
 
<selectable>true</selectable>
 
<drawerType>MapMeshAndRealTime</drawerType>
 
<surfaceNeeded>Light</surfaceNeeded>
 
<constructionEffect>ConstructMetal</constructionEffect>
 
<repairEffect>Repair</repairEffect>
 
</ThingDef>
 
 
 
</Buildings></source>
 
 
 
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 ===
 
 
 
Inside the <code>Buildings</code> tag and after <code>BuildingBase</code>, we’ll make a ThingDef called <code>SimpleBlock</code>:
 
 
 
<source lang="xml">
 
<ThingDef ParentName="BuildingBase">
 
<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>
 
<Overdraw>false</Overdraw>
 
<designationCategory>Structure</designationCategory>
 
<staticSunShadowHeight>0.5</staticSunShadowHeight>
 
<blockLight>true</blockLight>
 
 
<defName>SimpleBlock</defName>
 
<label>Simple block</label>
 
<description>An ugly thing.</description>
 
<texturePath>Things/Building/SimpleBlock_Atlas</texturePath>
 
<uiIconPath>Things/Building/SimpleBlock_MenuIcon</uiIconPath>
 
<maxHealth>50</maxHealth>
 
<flammability>0.1</flammability>
 
<workToBuild>100</workToBuild>
 
<mineable>false</mineable>
 
<size>(1,1)</size>
 
<costList>
 
<li>
 
<thingDef>Metal</thingDef>
 
<count>7</count>
 
</li>
 
</costList>
 
<filthLeavings>
 
<li>
 
<thingDef>SlagRubble</thingDef>
 
<count>2</count>
 
</li>
 
</filthLeavings>
 
<designationHotKey>Z</designationHotKey>
 
</ThingDef></source>
 
 
 
Hopefully, you’ll be able to understand what each property is once you read the page on [[ThingDef|ThingDef]].
 
 
 
Okay, we’re done with our simple block! Onto the next part!
 
 
 
=== Creating resources ===
 
 
 
To make our block actually visible, we need to add resources. In our mod’s root folder, make a new folder called <code>Textures</code>. Inside of that, make another called <code>Things</code>, and inside of that, make yet another folder called <code>Building</code>. Enter it.
 
 
 
Make two PNG images: your actual block called SimpleBlock_Atlas which will be 64x64, then another called SimpleBlock_MenuIcon which will also be 64x64.
 
 
 
== Finishing touches ==
 
 
 
We need to identify our mod so that RimWorld can recognize it. Browse back to the mod’s root folder and create a new folder called <code>About</code>. Inside of it, create a new XML called <code>About.xml</code>. It should look like this:
 
 
 
<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 3</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]]
 

Latest revision as of 11:50, 6 February 2019