Editing Module:Test/data/doc

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:
== Transformation rules ==
+
== Herein lie the (current) ad hoc rules for getting from an XML to a Lua table ==
 
 
=== RimWorld version ===
 
Version is added to the beginning of each generated Lua table.
 
 
 
<pre>
 
return {
 
 
 
  version = "1.2.2753",
 
  ...
 
</pre>
 
  
 
=== Elements with attributes ===
 
=== Elements with attributes ===
Create a new subelement and move all of the attributes to their own subelements within it.
+
Move into subkey with exact name.
 
 
=== *Def elements ===
 
<defName> is used as part of the index for the main Def table.
 
  
Additional attributes added: "DLC", "FileName".
+
=== Def keys ===
 +
defName is used as an index for the main Def table. defName remains as a subkey to the table.
  
 
<pre>
 
<pre>
Line 26: Line 14:
 
</pre>
 
</pre>
  
transforms to:
+
becomes
  
 
<pre>
 
<pre>
["ThingDef:Hare"] = {
+
["Hare"] = {
   ["_attrib_"] = {
+
   ["ParentName"] = "BaseHare",
    ["ParentName"] = "BaseHare",
+
   ["defName"] = "Hare",
    ["FileName"] = "Races_Animal_Hares.xml",
+
   ["label"] = "hare",
    ["DLC"] = "Core",
 
  },
 
   ["defName"] = "Snowhare",
 
   ["label"] = "snowhare",
 
 
   ...
 
   ...
 
</pre>
 
</pre>
  
Parent (abstract) Def:
+
Parent Def that gets inherited (Name becomes the key, no defName):
  
 
<pre>
 
<pre>
Line 50: Line 34:
 
</pre>
 
</pre>
  
transforms to:
+
becomes
  
 
<pre>
 
<pre>
["ThingDef:BaseHare"] = {
+
["BaseHare"] = {
   ["_attrib_"] = {
+
   ["Abstract"] = true,
    ["Abstract"] = "True",
+
  ["ParentName"] = "AnimalThingBase",
    ["ParentName"] = "AnimalThingBase",
+
   ["statBases"] = {
    ["Name"] = "BaseHare",
+
    ["MoveSpeed"] = 6.0,
    ["FileName"] = "Races_Animal_Hares.xml",
+
    ["MarketValue"] = 50,
    ["DLC"] = "Core",
+
    ...
   },
 
    ["statBases"] = {
 
      ["MoveSpeed"] = 6.0,
 
      ["MarketValue"] = 50,
 
  ...
 
 
</pre>
 
</pre>
  
=== List elements without children ===
+
=== <nowiki><li></nowiki> elements enclosing simple values ===
 
Get transformed into ordered lists (numerically indexed Lua tables).
 
Get transformed into ordered lists (numerically indexed Lua tables).
  
Line 77: Line 56:
 
</pre>
 
</pre>
  
transforms to:
+
becomes
  
 
<pre>
 
<pre>
Line 88: Line 67:
 
Note: a comma after the last item in a list is not flagged as an error in Lua.
 
Note: a comma after the last item in a list is not flagged as an error in Lua.
  
=== List elements with children ===
+
=== <nowiki><li></nowiki> elements enclosing multiple items ===
  
 
<pre>
 
<pre>
Line 107: Line 86:
 
</pre>
 
</pre>
  
transforms to:
+
becomes
  
 
<pre>
 
<pre>
Line 125: Line 104:
 
},
 
},
 
</pre>
 
</pre>
 
=== List elements with a single attribute Class ===
 
The value of the "Class" attribute is used to rename the <nowiki><li></nowiki>.
 
 
<pre>
 
<comps>
 
  <li Class="CompProperties_Glower">
 
    <glowRadius>10</glowRadius>
 
...
 
</pre>
 
 
transforms to:
 
 
<pre>
 
comps = {
 
  CompProperties_Glower = {
 
    glowRadius = 10,
 
...
 
</pre>
 
 
=== Components ===
 
 
It would be useful to have some of the more used components. They can then be queried for additional functionality that some game objects have.
 
 
They can be numbered tables or, as in some of the examples above, string indexed. String indexes, in general, are simpler to use. Numeric tables I have to search through.
 
 
See [[#List elements with a single attribute Class]]
 
  
 
=== Ranges (1~2) ===
 
=== Ranges (1~2) ===
<pre><overdoseSeverityOffset>0.18~0.35</overdoseSeverityOffset></pre>
+
: TODO
transforms to:
 
<pre>overdoseSeverityOffset = { ["<"]=0.18, [">"]=0.35 },</pre>
 
  
 
=== Curve points ===
 
=== Curve points ===
 
Curves pop up in a lot of places so additional support functions for those might be in order.
 
 
Min, max, maybe average... things like that. Some (like litterSizeCurve) have a fixed amount of points (correction: even for litterSizeCurve this is not true) so you could just retrieve the first one or last (fourth), but this is not the case for all of them and is a bit ugly. Whatever the case, additional processing with wiki syntax would have to be used. This is bad (and to be avoided if possible).
 
 
 
<pre>
 
<pre>
 
<litterSizeCurve>
 
<litterSizeCurve>
Line 174: Line 119:
 
</pre>
 
</pre>
  
transforms to:
+
becomes
  
 
<pre>
 
<pre>
Line 186: Line 131:
 
},
 
},
 
</pre>
 
</pre>
 
=== Descriptions ===
 
 
Because of some exceptions in Royalty Defs, <description> content has to be wrapped in double square brackets (Lua multiline syntax).
 
 
=== MayRequire attribute ===
 
Removed.
 
  
 
== Issues ==
 
== Issues ==
  
=== One (data) file to rule them all ===
+
* One data file or smaller ones split by categories (buildings, races, items, etc.).
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.
Single:
+
* Some pieces of the puzzle are in game code so until more files are processed, can't say what else will pop up.
* simplicity
+
* Can't keep semi-manually processing the xml files... it's lunacy.
** versioning
 
** uploading
 
 
 
Split:
 
* dynamic loading
 
 
 
=== Inheritance (interaction with parser) ===
 
Inheritance can be handled by the parser or the module. If the parser handles it, then for any change the dataset needs to be recreated so I'm leaning towards letting the module take care of that. In this case the only purpose of the parser is to filter data and transform it into something Lua can use.
 
 
 
== TODO ==
 
* Implement filtering for components (any list item that follows the same pattern)
 
 
 
<includeonly>[[Category:Module]]</includeonly>
 
<noinclude>[[Category:Module documentation]]</noinclude>
 

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)