From RimWorld Wiki
Jump to navigation Jump to search

This is the documentation page for Module:Test/data

Herein lie the (current) ad hoc rules for getting from an XML to a Lua table

Elements with attributes

Move into subkey with exact name.

Def keys

defName is used as an index for the main Def table. defName remains as a subkey to the table.

<ThingDef ParentName="BaseHare">


["Hare"] = {
  ["ParentName"] = "BaseHare",
  ["defName"] = "Hare",
  ["label"] = "hare",

Parent Def that gets inherited (Name becomes the key, no defName):

<ThingDef Abstract="True" ParentName="AnimalThingBase" Name="BaseHare">


["BaseHare"] = {
  ["Abstract"] = true,
  ["ParentName"] = "AnimalThingBase",
  ["statBases"] = {
    ["MoveSpeed"] = 6.0,
    ["MarketValue"] = 50,

<li> elements enclosing simple values

Get transformed into ordered lists (numerically indexed Lua tables).



["tradeTags"] = {

Note: a comma after the last item in a list is not flagged as an error in Lua.

<li> elements enclosing multiple items



["lifeStageAges"] = {
    ["def"] = "AnimalBaby",
    ["minAge"] = 0,
    ["def"] = "AnimalJuvenile",
    ["minAge"] = 0.25,
    ["def"] = "AnimalAdult",
    ["minAge"] = 0.5,

Ranges (1~2)


Curve points

    <li>(1.0, 0)</li>
    <li>(1.5, 1)</li>
    <li>(2.0, 1)</li>
    <li>(2.5, 0)</li>


["litterSizeCurve"] = {
  ["points"] = {
    {0.5, 0},
    {1, 1},
    {1.5, 1},
    {2.0, 0},


  • One data file or smaller ones split by categories (buildings, races, items, etc.).
  • A pro for separation might be that not everything has to be loaded to get relevant data (load only relevant files).
  • Until a more final version of the data is seen, the size of the whole thing is a bit unknown but shouldn't be too big to prevent the "one file" option. A definite pro for the one file option is the simplicity of updating - upload one file, done.
  • Some pieces of the puzzle are in game code so until more files are processed, can't say what else will pop up.
  • Can't keep semi-manually processing the xml files... it's lunacy.