Difference between revisions of "Module:Test/doc"

From RimWorld Wiki
Jump to navigation Jump to search
(Created page with "'''This is a work in progress. It's still quite useless at the moment.''' == Description == This module is used to obtain information about certain game objects. It uses data...")
 
m
Line 1: Line 1:
'''This is a work in progress. It's still quite useless at the moment.'''
+
'''This module is used for development. Even if it works at the moment it might break at any time.'''
  
 
== Description ==
 
== Description ==
This module is used to obtain information about certain game objects.
+
 
It uses data stored in the subpages of the module.
+
This module is used to get information about game objects.
The data that is in those subpages is gathered from Defs in the game's XML files.
+
It uses data stored in subpages of the module which is gathered from the game's XML files.
 +
Its main purpose is to populate the contents of 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 "OminvoreRoughAnimal" is not entirely helpful.
  
 
== Usage ==
 
== Usage ==
 +
 
<code><nowiki>
 
<code><nowiki>
{{#invoke:DefInfo|query|type|object|property}}
+
{{#invoke:Test|query|<def id>|...|<tag>}}
 
</nowiki></code>
 
</nowiki></code>
  
; type
+
; <def id>
: For now, the only type that is available is: Races. More will be added.
+
: A string needed to identify a Def. Works with defName or label.  
  
; object
+
; ...
: If we're querying Races, then, an object is for example: Hare, Lynx, Lancer, LabradorRetriever, ... (defNames are used).
+
: Additional numbered arguments are here to help uniquely identify the final argument (tag). If the wanted tag is unique within a Def tree, then the additional parameters are not needed.
 +
 
 +
; <tag>
 +
: tag defines data to be retrieved.
  
; property
 
: MoveSpeed, description, baseBodySize, ...
 
  
NOTE: What you can use in <code>object</code> and <code>property</code> parameters is not strictly defined and some properties can't be dependably obtained (tags that appear multiple times such as those in sublists - work in progress).
 
  
 
== Examples ==
 
== Examples ==
<code><nowiki>{{#invoke:DefInfo|query|Races|Hare|description}}</nowiki></code>
 
  
will return:
+
=== strings, numbers, booleans ===
 +
 
 +
<code><nowiki>{{#invoke:Test|query|Fox_Fennec|description}}</nowiki></code>
 +
 
 +
{{#invoke:Test|query|Fox_Fennec|description}}
 +
 
 +
<code><nowiki>{{#invoke:Test|query|fennec fox|description}}</nowiki></code>
 +
 
 +
{{#invoke:Test|query|fennec fox|description}}
 +
 
 +
<code><nowiki>{{#invoke:Test|query|Fox_Fennec|MoveSpeed}}</nowiki></code>
 +
 
 +
{{#invoke:Test|query|Fox_Fennec|MoveSpeed}}
 +
 
 +
<code><nowiki>{{#invoke:Test|query|Caribou|herdAnimal}}</nowiki></code>
 +
 
 +
{{#invoke:Test|query|Caribou|herdAnimal}}
 +
 
 +
"herdAnimal" is located in a branch of the main Def called "races" but because it appears nowhere else in the Def no additional parameters are needed to uniquely identify it.
 +
 
 +
The following query would retrieve the same data (just as an example) but with the use of an additional argument.
 +
 
 +
<code><nowiki>{{#invoke:Test|query|Caribou|race|herdAnimal}}</nowiki></code>
 +
 
 +
{{#invoke:Test|query|Caribou|race|herdAnimal}}</nowiki>
 +
 
 +
=== numbered lists (tradeTags) ===
  
{{#invoke:DefInfo|query|Races|Hare|description}}
+
* TODO: define a way to get list counts
  
<noinclude>[[Category:Module documentation]]</noinclude>
+
=== sibling queries (lifeStageAges or tools) ===

Revision as of 03:16, 14 April 2021

This module is used for development. Even if it works at the moment it might break at any time.

Description

This module is used to get information about game objects. It uses data stored in subpages of the module which is gathered from the game's XML files. Its main purpose is to populate the contents of 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 "OminvoreRoughAnimal" is not entirely helpful.

Usage

{{#invoke:Test|query|<def id>|...|<tag>}}

<def id>
A string needed to identify a Def. Works with defName or label.
...
Additional numbered arguments are here to help uniquely identify the final argument (tag). If the wanted tag is unique within a Def tree, then the additional parameters are not needed.
<tag>
tag defines data to be retrieved.


Examples

strings, numbers, booleans

{{#invoke:Test|query|Fox_Fennec|description}}


{{#invoke:Test|query|fennec fox|description}}


{{#invoke:Test|query|Fox_Fennec|MoveSpeed}}


{{#invoke:Test|query|Caribou|herdAnimal}}


"herdAnimal" is located in a branch of the main Def called "races" but because it appears nowhere else in the Def no additional parameters are needed to uniquely identify it.

The following query would retrieve the same data (just as an example) but with the use of an additional argument.

{{#invoke:Test|query|Caribou|race|herdAnimal}}

</nowiki>

numbered lists (tradeTags)

  • TODO: define a way to get list counts

sibling queries (lifeStageAges or tools)