Module:NpcData/doc: Difference between revisionsGive feedback
No edit summary |
Gammaton32 (talk | contribs) →Available Functions: outdated example |
||
| (5 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
This module allows you to display stats for any NPC (Non-Player Character) from the game's data files which can be found here [[Data:NpcData.json]]. | This module allows you to display stats for any NPC (Non-Player Character) from the game's data files which can be found here [[Data:NpcData.json]]. For most uses, it is recommended to use the {{tl|NpcData}} template. | ||
== How to Use == | == How to Use == | ||
| Line 9: | Line 9: | ||
== Available Functions == | == Available Functions == | ||
=== Get a Single Stat (`get_npc_var`) === | === Get a Single or Nested Stat (`get_npc_var`) === | ||
This is the | This is the primary function for retrieving NPC data. It can get a simple top-level stat or traverse deeply into nested objects and arrays (up to 6 levels deep via the template). | ||
'''Syntax''' | '''Syntax''' | ||
<code><nowiki>{{#invoke:NpcData|get_npc_var|NPC Name| | <code><nowiki>{{#invoke:NpcData|get_npc_var|NPC Name|Key 1|Key 2|...|Rounding}}</nowiki></code> | ||
'''Parameters''' | '''Parameters''' | ||
* '''NPC Name:''' The internal key for the NPC. | * '''NPC Name:''' The internal key for the NPC (e.g., `npc_boss_tier2`, `trooper_normal`). | ||
* ''' | * '''Key 1, Key 2, ...:''' The path to the stat you want. | ||
* '''Rounding:''' (Optional) A number to round the result to that many significant figures. | ** For a simple stat, this is one key (e.g., `MaxHealth`). | ||
** For nested data, provide each key in order (e.g., `RebirthModifier`, `RespawnDelay`). | |||
** For arrays (lists), use the position number as a key (e.g., `IntrinsicModifiers`, `1`, `BULLET_ARMOR_DAMAGE_RESIST`). | |||
* '''Rounding:''' (Optional) A number to round the result to that many significant figures. This should always be the last parameter. | |||
'''Examples''' | '''Examples''' | ||
* To get the | * To get the max health of a Normal Trooper: | ||
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var| | ** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_normal|MaxHealth}}</nowiki></code> | ||
** '''Result:''' {{#invoke:NpcData|get_npc_var| | ** '''Result:''' {{#invoke:NpcData|get_npc_var|trooper_normal|MaxHealth}} | ||
* To get the | * To get the name of a Walker's second ability (nested in BoundAbilities): | ||
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var| | ** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}}</nowiki></code> | ||
** '''Result:''' {{#invoke:NpcData|get_npc_var| | ** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}} | ||
* | * To get a value from a list of modifiers (nested array): | ||
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var| | ** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|IntrinsicModifiers|1|BULLET_ARMOR_DAMAGE_RESIST}}</nowiki></code> | ||
** '''Result:''' {{#invoke:NpcData|get_npc_var| | ** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|IntrinsicModifiers|1|BULLET_ARMOR_DAMAGE_RESIST}} | ||
* If a path is incorrect, an error message will show the full path attempted: | |||
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_normal|InvalidKey|Stat}}</nowiki></code> | |||
** '''Result:''' <span class="error">Error: Key "InvalidKey" not found in path "trooper_normal".</span> | |||
** '''Code:''' <code><nowiki>{{#invoke:NpcData| | |||
** '''Result:''' | |||
</ | |||