Module:NpcData/doc: Difference between revisionsGive feedback
mNo edit summary |
Updated doc to reflect the current code |
||
| Line 10: | Line 10: | ||
=== Get a Single or Nested Stat (`get_npc_var`) === | === Get a Single or Nested Stat (`get_npc_var`) === | ||
This is the primary function for retrieving NPC data. It can get a simple top-level stat or traverse into nested objects and arrays | 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''' | ||
| Line 16: | Line 16: | ||
'''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. | * '''Key 1, Key 2, ...:''' The path to the stat you want. | ||
** For a simple stat, this is | ** For a simple stat, this is one key (e.g., `MaxHealth`). | ||
** For | ** 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. | * '''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 max health of a | * 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 Respawn Delay for a Rejuvenator (nested object): | ||
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var| | ** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|citadel_item_pickup_rejuv|RebirthModifier|RespawnDelay}}</nowiki></code> | ||
** '''Result:''' {{#invoke:NpcData|get_npc_var| | ** '''Result:''' {{#invoke:NpcData|get_npc_var|citadel_item_pickup_rejuv|RebirthModifier|RespawnDelay}} | ||
* To get the name of | * To get the name of a Walker's second ability (nested in BoundAbilities): | ||
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities| | ** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}}</nowiki></code> | ||
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities| | ** '''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:''' | |||