Editing Modding Tutorials/XML Defs

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 28: Line 28:
  
 
=Common errors=
 
=Common errors=
{{Main|Modding Tutorials/Troubleshooting}}
 
 
For beginning coders, the most common errors are '''formatting or syntax''' errors. A missing bracket, unclosed tag, empty file - these can all be avoided by using the proper tools. Get a text editor (or plug-in) that highlights or warns for these basic issues. RimWorld will not warn you: at best it will overload you with errors, at worst it will refuse to start.
 
For beginning coders, the most common errors are '''formatting or syntax''' errors. A missing bracket, unclosed tag, empty file - these can all be avoided by using the proper tools. Get a text editor (or plug-in) that highlights or warns for these basic issues. RimWorld will not warn you: at best it will overload you with errors, at worst it will refuse to start.
 +
 +
Other common errors are related to resolving cross-references. For instance: def A wants to use def B, but def B can't be found. These cross-references are by ''defName''. Both Type and defName have to match. In our earlier example, if there isn't a ''SoundDef'' with the ''Slurp'' defName, the game will log the following error:
 +
 +
        Could not resolve cross-reference: No SoundDef named Slurp found to give to ThingDef SomeName.
 +
 +
If the game can't find a cross-reference in a list, the error is slightly different:
 +
 +
        Could not resolve cross-reference to Verse.ThingCategoryDef named BuldingsPower (wanter=thingCategories)
 +
 +
where ''wanter=thingCategories'' is an optional addition, but it's the xml tag containing the misspelled "Bu'''i'''ldingsPower".<br/><br/>
 +
 +
Other errors are:
 +
* Defining the same field/tag twice
 +
        XML RimWorld.ThoughtDef defines the same field twice: stackLimit.
 +
        Field contents: 1.
 +
        Whole XML: <A lot of XML>
 +
 +
In this example, there is a ThoughtDef with two ''stackLimit'' entries. Likely the result of two mods patching the same Def. The first mod wins.
 +
 +
* Missing a Type
 +
        Could not find type named TurretExtensions.CompProperties_Upgradable from node <A lot of XML>
 +
This happens when an XML mod refers to a type which isn't loaded. In practice, a missing (DLL) dependency, a (DLL) dependency which couldn't be loaded due to earlier errors, or an outdated mod.<br/>
 +
 +
* Referencing a non-existing field
 +
<source lang ="xml">        XML error: <costStaffCount>50</costStaffCount> doesn't correspond to any field in type ThingDef. Context: <ThingDef ParentName="SculptureBase"><defName>SculptureSmall</defName><label>small sculpture</label><description>An artistic sculpture.</description><stuffCategories><li>Metallic</li><li>Woody</li><li>Stony</li></stuffCategories><costStaffCount>50</costStaffCount></ThingDef></source>
 +
 +
This happens when the parentnode (in this case ''ThingDef'') does not contain an entry for the ''costSt'''a'''ffCount'' tag. This could be caused by a simple typo, by putting the tag in the wrong node, by a missing dependency, as a result of earlier errors, or an outdated mod. XML can only correspond to fields that are defined in C#.<br/>
  
 
=Note about (solving) XML errors=
 
=Note about (solving) XML errors=
 
XML errors '''cascade'''. Behind the scenes, RimWorld combines all Defs inside one massive XML document. If one <tag> is missing its closing </tag>, none of the XML will be readable by the parser and you will be greeted by a wall of red errors. Find the first XML error, and fix that one. Do not go chasing the other errors just yet. Reload the game, then fix the next error (if any).
 
XML errors '''cascade'''. Behind the scenes, RimWorld combines all Defs inside one massive XML document. If one <tag> is missing its closing </tag>, none of the XML will be readable by the parser and you will be greeted by a wall of red errors. Find the first XML error, and fix that one. Do not go chasing the other errors just yet. Reload the game, then fix the next error (if any).
 
[[Category: Modding tutorials]]
 
[[Category: Modding]]
 

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)

This page is a member of 1 hidden category: