Editing Module:Test/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:
__NOEDITSECTION__
+
__NOTOC__ __NOEDITSECTION__
 
'''This module is used for development.'''
 
'''This module is used for development.'''
  
== Purpose ==
+
'''Even if it works at the moment it might break at any time.'''
  
This module is used to query information from the uploaded and parsed game files.
+
'''Parser is done (needs a few more finishing touches) so any data that is missing can be easily added.'''
 +
 
 +
'''At the moment the dataset has ThingDefs, BiomeDefs and DamageDefs (filtered).'''
 +
 
 +
== Description ==
 +
 
 +
This module is used to query information from the parsed (and filtered) game's definition files.
  
 
Its main purpose is to populate the infoboxes.
 
Its main purpose is to populate the infoboxes.
 +
 +
Values retrieved are those defined in the files so they may need to be processed to be user friendly. For example "foodType" that holds the value "OmnivoreRoughAnimal" is not entirely helpful. (TODO: This could be automatically converted to something more recognizable.)
  
 
== Usage ==
 
== Usage ==
  
A note on the order of named parameters. All of the parameters that look like <code>...=...</code> are called named parameters and their order is not important (this is true for all templates).
+
A note on the order of parameters. All of the parameters that begin with <code>somelabel=...</code> are called named parameters and their order is not important (as is the general case with parameters for templates).
  
 +
<hr/>
 
=== query ===
 
=== query ===
<pre><nowiki>{{#invoke:Test|query|<def ID>[|...|][|tag|][|sibling=...]}}</nowiki></pre>
 
  
The work-horse. Output varies based on use:
+
The work-horse. Output varies based on use. If simple values are queried it will return the string. If lists are queried it will return nothing but call <code><nowiki>{{#vardefine}}</nowiki></code> for all the simple values within it. What got defined can be seen in the page's log.
: If only the <code><def ID></code> parameter is set, it will show the whole Def in the log.
+
 
: If simple values are queried it will return them.
+
<pre><nowiki>{{#invoke:Test|query|<def ID>|[...|...|...]|[tag]|[sibling=...]}}</nowiki></pre>
: If lists are queried it will return nothing but call <code><nowiki>{{#vardefine}}</nowiki></code> on all the simple values within it. What got defined can be seen in the page's log.
+
 
 +
<code><def ID></code>
 +
 
 +
: This parameter identifies the Def so it is mandatory. It can take two forms:
 +
 
 +
: <code>defName=<defName></code>
 +
:: <defName> ''(case sensitive)'' should be replaced with the actual defName of a Def.
  
Named parameters:
+
: <code>label=<label></code>
 +
:: <label> ''(case insensitive)'' should be replaced with the actual label of a Def.
  
: <code><def ID></code>
+
<code>[...|...|...]</code>  
 +
: Additional arguments are here to help uniquely identify the final argument [tag]. If the wanted tag is already unique within a Def tree, then additional parameters are not needed.
  
:: This parameter identifies the Def so it is mandatory. It can take two forms, if both are defined then <code>defName</code> takes preference.
+
<code>[tag]</code>
 +
: The final parameter is just a normal numbered parameter but because it is the last one, it is mentioned here so it can be referred to.
  
::: <code>defName=<defName></code>
+
<code>[sibling=<value>]</code>
:::: <code><defName></code> <small>''(case sensitive)''</small> should be replaced with the actual defName of a Def.
+
: Allows querying for something if we know its sibling's value (works only for values at the moment). It does not have to be at the end because named arguments do not depend on the order.
  
::: <code>label=<label></code>
+
<hr/>
:::: <code><label></code> <small>''(case insensitive)''</small> should be replaced with the actual label of a Def.
+
=== count ===
  
: <code>[sibling=...]</code> <small>''(optional)''</small> <small>''(case sensitive)''</small>
+
<pre><nowiki>{{#invoke:Test|count|<def ID>|[...|...|...]|[tag]|[sibling=...]}}</nowiki></pre>
::: Allows querying for something if we know its sibling's value (works only for values at the moment).
 
  
Anonymous parameters:
+
Arguments are the same as for [[#query]]. It's basically a wrapped up query.
  
: <code>[|...|]</code> <small>''(optional)''</small> <small>''(case sensitive)''</small>
+
Because count (if not 0) means that a table was counted - it will also be displayed in the log.
:: Anonymous paramaters before the last one (<code>[tag]</code>) are here to help uniquely identify it. If the <code>[tag]</code> is already unique within a Def tree, then these additional parameters are not needed.
 
  
: <code>[|tag|]</code> <small>''(optional)''</small> <small>''(case sensitive)''</small>
+
<hr/>
:: The final anonymous parameter defines what is to be queried.
+
=== getDefName ===
  
=== count ===
+
Used to retrieve a Def's defName if we know the label. Most of the wiki pages are labels of Defs so this can come in handy.
<pre><nowiki>{{#invoke:Test|count|<def ID>[|...|][|tag|][|sibling=...]}}</nowiki></pre>
 
  
Parameters are the same as for <code>query</code>. It's basically a wrapped up query that behaves a bit differently.
+
<pre><nowiki>{{#invoke:Test|getDefName|<label>}}</nowiki></pre>
  
The difference is in how it handles lists. If a list is queried, unlike <code>query</code>, it will return the length of the list.
+
<code><label></code>
 +
: Def's label (not case sensitive)
  
 
== How-to ==
 
== How-to ==
 +
 +
=== Get defName if we know label ===
 +
 +
<code><nowiki>{{#invoke:Test|getDefName|feNNec fOx}}</nowiki></code>
 +
 +
<code>{{#invoke:Test|getDefName|feNNec fOx}}</code>
  
 
=== Take a look at a Def ===
 
=== Take a look at a Def ===
  
 
<code><nowiki>{{#invoke:Test|query|label=desert}}</nowiki></code>
 
<code><nowiki>{{#invoke:Test|query|label=desert}}</nowiki></code>
 
+
{{#invoke:Test|query|label=desert}}
<code>{{#invoke:Test|query|label=desert}}</code>
+
''(check the log)''
 
 
Data is in the log.
 
  
 
=== Retrieve a simple value ===
 
=== Retrieve a simple value ===
Line 113: Line 132:
  
 
<code>{{#invoke:Test|query|label=guinea pig|minAge|sibling=AnimalAdult}}</code>
 
<code>{{#invoke:Test|query|label=guinea pig|minAge|sibling=AnimalAdult}}</code>
 
<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)