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__
+
'''This is a work in progress. It's still quite useless at the moment.'''
'''This module is used for development.'''
 
  
== Purpose ==
+
== Description ==
 
+
This module is used to obtain information about certain game objects.
This module is used to query information from the uploaded and parsed game files.
+
It uses data stored in the subpages of the module.
 
+
The data that is in those subpages is gathered from Defs in the game's XML files.
Its main purpose is to populate the infoboxes.
 
  
 
== Usage ==
 
== Usage ==
 +
<code><nowiki>
 +
{{#invoke:DefInfo|query|type|object|property}}
 +
</nowiki></code>
  
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).
+
; type
 
+
: For now, the only type that is available is: Races. More will be added.
=== query ===
 
<pre><nowiki>{{#invoke:Test|query|<def ID>[|...|][|tag|][|sibling=...]}}</nowiki></pre>
 
 
 
The work-horse. Output varies based on use:
 
: 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.
 
: 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.
 
 
 
Named parameters:
 
 
 
: <code><def ID></code>
 
 
 
:: 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>defName=<defName></code>
 
:::: <code><defName></code> <small>''(case sensitive)''</small> should be replaced with the actual defName of a Def.
 
 
 
::: <code>label=<label></code>
 
:::: <code><label></code> <small>''(case insensitive)''</small> should be replaced with the actual label of a Def.
 
 
 
: <code>[sibling=...]</code> <small>''(optional)''</small> <small>''(case sensitive)''</small>
 
::: Allows querying for something if we know its sibling's value (works only for values at the moment).
 
 
 
Anonymous parameters:
 
 
 
: <code>[|...|]</code> <small>''(optional)''</small> <small>''(case sensitive)''</small>
 
:: 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>
 
:: The final anonymous parameter defines what is to be queried.
 
 
 
=== count ===
 
<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.
 
 
 
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.
 
 
 
== How-to ==
 
 
 
=== Take a look at a Def ===
 
 
 
<code><nowiki>{{#invoke:Test|query|label=desert}}</nowiki></code>
 
 
 
<code>{{#invoke:Test|query|label=desert}}</code>
 
 
 
Data is in the log.
 
 
 
=== Retrieve a simple value ===
 
 
 
<code><nowiki>{{#invoke:Test|query|defName=Caribou|description}}</nowiki></code>
 
 
 
<code>{{#invoke:Test|query|defName=Caribou|description}}</code>
 
 
 
=== Dealing with lists ===
 
 
 
<code><nowiki>{{#invoke:Test|query|defName=Mech_Scyther|tools}}</nowiki></code>
 
 
 
<code>{{#invoke:Test|query|defName=Mech_Scyther|tools}}</code>
 
 
 
When a list is retrieved there will be no output but the log will contain a list of defined variables.
 
 
 
For convenience the list is reprinted here:
 
 
 
<pre>
 
tools_1_linkedBodyPartsGroup = LeftBlade
 
tools_1_cooldownTime = 2
 
tools_1_label = left blade
 
tools_1_DPS = 10
 
tools_1_power = 20
 
tools_1_capacities_1 = Cut
 
tools_1_capacities_2 = Stab
 
tools_2_linkedBodyPartsGroup = RightBlade
 
tools_2_cooldownTime = 2
 
tools_2_label = right blade
 
tools_2_DPS = 10
 
tools_2_power = 20
 
tools_2_capacities_1 = Cut
 
tools_2_capacities_2 = Stab
 
tools_3_linkedBodyPartsGroup = HeadAttackTool
 
tools_3_capacities_1 = Blunt
 
tools_3_label = head
 
tools_3_DPS = 4.5
 
tools_3_chanceFactor = 0.2
 
tools_3_power = 9
 
tools_3_cooldownTime = 2
 
</pre>
 
 
 
All of the above can be accessed with the use of <code><nowiki>{{#var:...}}</nowiki></code>.
 
  
<code><nowiki>{{#var:tools_1_DPS}}</nowiki></code>
+
; object
 +
: If we're querying Races, then, an object is for example: Hare, Lynx, Lancer, LabradorRetriever, ... (defNames are used).
  
<code>{{#var:tools_1_DPS}}</code>
+
; property
 +
: MoveSpeed, description, baseBodySize, ...
  
''DPS'' is not a normal member of this table but has been added with Lua. Let's call it a virtual field.
+
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).
  
=== Retrieve something if a sibling is known ===
+
== Examples ==
 +
<code><nowiki>{{#invoke:DefInfo|query|Races|Hare|description}}</nowiki></code>
  
<code><nowiki>{{#invoke:Test|query|label=guinea pig|minAge|sibling=AnimalAdult}}</nowiki></code>
+
will return:
  
<code>{{#invoke:Test|query|label=guinea pig|minAge|sibling=AnimalAdult}}</code>
+
{{#invoke:DefInfo|query|Races|Hare|description}}
  
<includeonly>[[Category:Module]]</includeonly>
 
 
<noinclude>[[Category:Module documentation]]</noinclude>
 
<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)