แม่แบบ:Dv

จาก ARK Wiki
ไปยังการนำทาง ไปยังการค้นหา
Template-info.png Documentation

DV, or Dinosaur Values, serves as a one-stop database for data values that may frequently change during ARK's development that enables users to edit a single template rather than each individual creature's page and any other pages these values might appear. This template is not intended to replace Cargo, rather the two can work in unison when this template is called on a semantic page.

Database

The database resides in Module:Dv/data and is a nested array (or table in Lua speech).

The first tier's keys is the creature's names. The next tier contains key-value pairs. A value can also be another array/table with key-value pairs, in an arbitrary depth.

The keys build the <attribute path>. For example, the path to the value 5 is attacks/1/melee/damage, or in other words {{ dv | dodo | attacks/1/melee/damage }}.

-- simplified syntax to show the principle, for the real syntax see Module:Dv/data

...
|
+- dodo
|  +- commonname: Dodo
|  +- group: Birds
|  +- ...
|  +- stats
|  |  +- health: 40
|  |  +- ...
|  +- attacks
|     +- 1
|        +- name: Melee
|        +- ...
|        +- melee
|           +- damage: 5
|
+- dodorex
|  +- ...
...
+- aberrantOverride
|  +- stats  -- a few stats that are different for most aberrant creatures
|     +- healthtamedmult: -0.04
|     +- ...
+- abberantdodo
   +- inherits: dodo
   +- overridewith: aberrantOverride
   +- commonname: Aberrant Dodo
   +- ...

There are two special keys, inherits and overridewith, which are considered only when they occur in the second tier. If inherits exists for a creature then the data are copied from the other creature which is named by the value. Then all data of the actual creature is recursively merged into. Values of existing keys will be overridden, non-existing keys with their values will be added. If also overridewith exists then the values of the named section will also be merged afterwards, overriding all previously added values.

So, in the example above the Aberrant Dodo is a copy of the non-aberrant Dodo, but with an own common name, and some overridden (or added) stats that are common for most aberrant creatures.

Common Usage

{{ dv | <name> | <attribute path> }}
{{ dv | <name> / <attribute path> }}
{{ dv | <name> | <attribute path part 1> | <attribute path part 2> }}

The parts of the path can be written combined with a slash / as separator or as individual parameters separated by |.

The attribute path needs to lead to a single value. Otherwise the text "path not specific enough" is returned.

If the path points to a non existing key nothing (an empty string) is returned.

Resolving the name

The <name> of the creature usually corresponds to its page name. The Template/Module Dv removes all characters other than A-Za-z0-9 (e.g. space, punctuation and accented characters) from the <name> parameter and converts it to lowercase. Then it checks if there is an alias defined in Module:Dv/aliases. The resulting name has to match with one of the keys of the first tier of the array/table defined in Module:Dv/data. Otherwise the text "creature data not found" is returned.

The same rule applies for the attribute path parts analogously, except the alias resolving.

Examples

{{dv|Allosaurus|stats/health}} will show "630"

{{dv|Allosaurus|stats|health}} will show "630"

{{dv|Allosaurus|stats}} will show "path not specific enough: allosaurus/stats"

{{dv|Allosaurus|stats/fortitude}} will show ""

{{dv|allo|stats/health}} will show "630"

{{dv|allo saur|stats/health}} will show "630"


{{dv|Woolly Rhino|KillXPBase}} will show "4"

{{dv|ptera|immobilizedby}} will show "Bola, Chain Bola, Bear Trap, Large Bear Trap, Plant Species Y Trap, Net Projectile"

{{dv|LIGHTNING WYVERN|DLC}} will show "Scorched Earth, Ragnarok, Genesis: Part 1"

Defining variables

As an alternative add the named parameter defineVars with no or an arbitrary prefix (equal sign is mandatory).

{{ dv | <name> | <attribute path> | defineVars= }}
{{ dv | <name> | <attribute path> | defineVars=prefix }}
{{ dv | <name> | <attribute path part 1> | <attribute path part 2> | defineVars=prefix }}

If the <attribute path> leads to a single value the behavior is the same as above. If it leads to a non-existing key then nothing (empty string) is returned. If it leads to an array/table then the text "variables defined" is the return value. In this case for each key-value pair a {{#vardefine:key|value}} is executed. If a value is a nested array/table then a variable with the current key and the string "table" is defined, and for each entry the key is prepended by the parent's path parts starting after the given <attribute path> and separated by slashes /. Additionally, if the prefix is not empty, all variable names are prepended by the prefix followed by a slash /.

{{#if: {{dv | Dodo | attacks/1 | defineVars=}} |
* Name: {{#var:name}}
{{#if: {{#var:melee}} <!-- contains "table" --> |
* Damage: {{#var:melee/damage}}
}}
}}
  • Name: Melee
  • Damage: 5

In the example above the return text "variables defined" is ignored, but needs to be there (or rather a non-empty string) to satisfy the condition for the #if:.

{{#if: {{dv | Dodo | stats | defineVars=prefix}} |
* Health: {{#var:prefix/health}}
}}
  • Health: 40