Difference between revisions of "Module:Test/doc"
m |
|||
Line 1: | Line 1: | ||
+ | __NOTOC__ | ||
'''This module is used for development.''' | '''This module is used for development.''' | ||
Line 8: | Line 9: | ||
== Description == | == Description == | ||
− | This module is used to | + | |
+ | 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. | ||
Line 24: | Line 26: | ||
<code><def ID></code> | <code><def ID></code> | ||
− | : This parameter | + | : This parameter identifies the Def so it is mandatory. It can take two forms: |
: <code>defName=<defName></code> | : <code>defName=<defName></code> | ||
− | :: <defName> should be replaced with the actual defName of a Def. | + | :: <defName> ''(case sensitive)'' should be replaced with the actual defName of a Def. |
: <code>label=<label></code> | : <code>label=<label></code> | ||
− | :: <label> should be replaced with the actual label of a Def. | + | :: <label> ''(case insensitive)'' should be replaced with the actual label of a Def. |
<code>[...|...|...]</code> | <code>[...|...|...]</code> | ||
− | : Additional arguments are here to help uniquely identify the final argument | + | : 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. |
<code>[tag]</code> | <code>[tag]</code> | ||
Line 40: | Line 42: | ||
<code>[sibling=...]</code> | <code>[sibling=...]</code> | ||
: Allows querying for something if we know a sibling value (works only for values at the moment, querying by keys or key/value pairs will most likely be added). It does not have to be at the end because named arguments do not depend on the order. (Might move this functionality to a separate function if the need arises). | : Allows querying for something if we know a sibling value (works only for values at the moment, querying by keys or key/value pairs will most likely be added). It does not have to be at the end because named arguments do not depend on the order. (Might move this functionality to a separate function if the need arises). | ||
− | |||
− | |||
− | |||
− | |||
=== count === | === count === | ||
Line 62: | Line 60: | ||
: Def's label (not case sensitive) | : Def's label (not case sensitive) | ||
− | == | + | == How-to == |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === Get a Def's defName using its label === | |
− | + | <code><nowiki>{{#invoke:Test|getDefName|feNNec fOx}}</nowiki></code> | |
− | |||
− | + | <code>{{#invoke:Test|getDefName|feNNec fOx}}</code> | |
− | + | === Take a look at a Def === | |
− | |||
− | + | <code><nowiki>{{#invoke:Test|query|label=desert}}</nowiki></code> | |
+ | {{#invoke:Test|query|label=desert}} | ||
+ | ''(check the log)'' | ||
− | + | === Retrieve a simple value === | |
− | |||
− | + | <code><nowiki>{{#invoke:Test|query|defName=Caribou|description}}</nowiki></code> | |
− | + | <code>{{#invoke:Test|query|defName=Caribou|description}}</code> | |
− | |||
− | + | === Retrieve a list === | |
− | |||
− | + | <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. | |
− | |||
− | + | === Retrieve something if a sibling is known === | |
− | + | <code><nowiki>{{#invoke:Test|query|label=guinea pig|minAge|sibling=AnimalAdult}}</nowiki></code> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <code>{{#invoke:Test|query|label=guinea pig|minAge|sibling=AnimalAdult}}</code> | |
− |
Revision as of 21:55, 16 May 2021
This module is used for development.
Even if it works at the moment it might break at any time.
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.
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
query
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 {{#vardefine}}
for all the simple values within it. What got defined can be seen in the page's log.
{{#invoke:Test|query|<def ID>|[...|...|...]|[tag]|[sibling=...]}}
<def ID>
- This parameter identifies the Def so it is mandatory. It can take two forms:
defName=<defName>
- <defName> (case sensitive) should be replaced with the actual defName of a Def.
label=<label>
- <label> (case insensitive) should be replaced with the actual label of a Def.
[...|...|...]
- 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.
[tag]
- This is the final value to be retrieved.
[sibling=...]
- Allows querying for something if we know a sibling value (works only for values at the moment, querying by keys or key/value pairs will most likely be added). It does not have to be at the end because named arguments do not depend on the order. (Might move this functionality to a separate function if the need arises).
count
{{#invoke:Test|count|<def ID>|[...|...|...]|[tag]|[sibling=...]}}
Arguments are the same as for #query. It's basically a wrapped up query.
Because count (if not 0) means that a table was counted - it will also be displayed in the log.
getDefName
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.
{{#invoke:Test|getDefName|<label>}}
<label>
- Def's label (not case sensitive)
How-to
Get a Def's defName using its label
{{#invoke:Test|getDefName|feNNec fOx}}
Script error: The function "getDefName" does not exist.
Take a look at a Def
{{#invoke:Test|query|label=desert}}
(check the log)
Retrieve a simple value
{{#invoke:Test|query|defName=Caribou|description}}
A large member of the deer family, well-adapted to life in cold climates. Caribou can be milked, but refuse to carry packs.
Retrieve a list
{{#invoke:Test|query|defName=Mech_Scyther|tools}}
When a list is retrieved there will be no output but the log will contain a list of defined variables.
Retrieve something if a sibling is known
{{#invoke:Test|query|label=guinea pig|minAge|sibling=AnimalAdult}}
0.3