Module:Npcinfo/data/doc

From Terraria Wiki
Jump to navigation Jump to search

Lua.svgThis is the documentation page for Module:Npcinfo/data.


Internal sub-module of Module:Npcinfo, which heavily relies on this module.

Provides a database with all statistics of every NPC (enemies, town NPCs, critters, etc.) in Terraria, taken from the source code. The database code was generated by Module:Npcinfo/datagen.

This database needs to be re-generated when the data generator (Module:Npcinfo/datagen) is updated, which is usually only the case after a Terraria patch. Re-generate it as follows:

  1. First invoke the genMeta function of the data generator. To do this, put the following wikicode on a sandbox page and save/preview it: <div style="white-space:pre">{{#invoke:Npcinfo/datagen|genMeta}}</div>. Copy the output and replace the respective lines here below the "DATA START" line with it.
  2. Then invoke the gen function, which generates the actual data for a set of NPCs. This function expects an NPC ID to start at and one to end at.
    • If you only want to re-generate the database entry of one NPC (e.g. the NPC with an ID of 42), put the following wikicode on a sandbox page and save/preview it: <div style="white-space:pre">{{#invoke:Npcinfo/datagen|gen|42|42}}</div>. Copy the output and replace the respective lines here with it.
    • If you want to re-generate the database entries of several NPCs (e.g. starting with the NPC with an ID of 142 and ending with the NPC with an ID of 163), put the following wikicode on a sandbox page and save/preview it: <div style="white-space:pre">{{#invoke:Npcinfo/datagen|gen|142|163}}</div>. Copy the output and replace the respective lines here with it.
    • If you want to re-generate the entire database (i.e. all NPCs), then you will need to do so in chunks, as the data generator cannot handle all NPCs at once. Put the following wikicode on a sandbox page and save/preview it: <div style="white-space:pre">{{#invoke:Npcinfo/datagen|gen|-65|34}}</div>. Copy the output and replace the respective lines here with it. Repeat with |35|134, then |135|234, and so on, until you reach the greatest NPC ID (687). Also feel free to try a larger interval.
Generally, the entire database should always be re-generated instead of only parts of it, to ensure it stays up-to-date (unless you know for sure that only a part has changed).