Модуль:Iteminfo/data/doc
Internal sub-module of Module:Iteminfo, which heavily relies on this module.
It provides a database with all statistics of every item in Terraria, taken from the source code ( ПК-издание 1.4.4.9). The database code was generated by Module:Iteminfo/datagen.
This database needs to be re-generated when the data generator (Module:Iteminfo/datagen) is updated, which is usually only the case after a Terraria patch. Re-generate it as follows:
-
Update the metadata of the database by invoking the
genMeta
function of the data generator:-
Put the following wikicode on a sandbox page (such as a page in your userspace like Special:MyPage/Sandbox, or Terraria Wiki:Sandbox) and preview (or save) it:
{{#tag:pre| {{#invoke:Iteminfo/datagen|genMeta}} }}
-
The output should consist of two lines; copy them.
-
Head to the "edit" tab of Module:Iteminfo/luadata and find the two lines which look similar to the ones you just copied. They should be near the top, below a "DATA START" line. Remove those two lines there and paste in their place the two lines that you copied.
-
Keep the edit screen of Module:Iteminfo/luadata open and do not save it yet.
-
-
Generate the actual data for a set of items by invoking the
gen
function. This function expects an item ID to start at and one to end at.Generally, you should always re-generate the entire database in order to ensure it stays up-to-date. If you know for sure that only a part (e.g. only one item) has changed, then you can re-generate only the database entry of that item.
-
If you only want to re-generate the database entry of one item (e.g. the item with an ID of 42):
-
Put the following wikicode on a sandbox page and preview (or save) it:
{{#tag:pre| {{#invoke:Iteminfo/datagen|gen|42|42}} }}
-
The output should consist of several lines (starting with
["42"] = {
and ending with},
); copy them.These lines are the entire database entry for the item with ID 42.
-
Go back to the edit screen of Module:Iteminfo/luadata and find the existing database entry for the item with ID 42. There should be a
["42"] = {
line somewhere, followed by a few lines that look similar to the ones you just copied, and followed by the closing},
line. Remove those lines and paste in their place the lines that you copied. -
Keep the edit screen of Module:Iteminfo/luadata open and do not save it yet.
-
-
If you want to re-generate the database entries of several items (e.g. starting with the item with an ID of 142 and ending with the item with an ID of 163):
-
Put the following wikicode on a sandbox page and preview (or save) it:
{{#tag:pre| {{#invoke:Iteminfo/datagen|gen|142|163}} }}
-
The output should consist of several lines (starting with
["142"] = {
and ending with},
); copy them.These lines are the entire database entries for the items with the IDs 142 through 163.
-
Go back to the edit screen of Module:Iteminfo/luadata and find the existing database entries for the items with the IDs 142 through 163. There should be a
["142"] = {
line somewhere, followed by a few attribute lines, and followed by the closing},
line, then["143"] = {
, more attribute lines, the next closing},
, and so on until["163"] = {
and the last closing},
line. Remove all those lines and paste in their place the lines that you copied. -
Keep the edit screen of Module:Iteminfo/luadata open and do not save it yet.
-
-
If you want to re-generate the entire database (i.e. all items) (this is preferred), then you will need to do so in chunks, as the data generator cannot handle all items at once.
-
Put the following wikicode on a sandbox page and preview (or save) it:
{{#tag:pre| {{#invoke:Iteminfo/datagen|gen|0|99}} }}
-
The output should consist of many lines (starting with
["0"] = {
and ending with},
); copy them.These lines are the entire database entries for the items with the IDs 0 through 99.
-
Go back to the edit screen of Module:Iteminfo/luadata and find the existing database entries for the items with the IDs 0 through 99. There should be a
["0"] = {
line near the top, followed by some attribute lines, and followed by the closing},
line, then["1"] = {
, more attribute lines, the next closing},
, and so on until["99"] = {
and the last closing},
line. Remove all those lines and paste in their place the lines that you copied. -
Repeat step a. with
|100|199
instead of|0|99
, copy the output, and replace the existing database entries for the items with the IDs 100 through 199 like in step c.Afterward repeat this with
|200|299
, then|300|399
, and so on, until you reach the greatest item ID (5455). Feel free to try a larger interval, e.g.|200|399
. The data generator will not work if the interval is too large. -
Keep the edit screen of Module:Iteminfo/luadata open and do not save it yet.
-
-
-
Now save Module:Iteminfo/luadata.
-
Transform the data in the right format by invoking the
convertToJsonData
function.-
Put the following wikicode on a sandbox page and preview (or save) it:
{{#tag:pre| {{#invoke:Iteminfo/datagen|convertToJsonData}} }}
-
The output should be very long. Ensure that it does not have the issues described on the talk page by finding the character
[
via your browser's search function (usually Ctrl + F). There should be exactly 6 occurrences (in["data"] = [=====[
and["nameDB"] = [=====[
).Copy the entire output.
-
Head to the "edit" tab of this module (Module:Iteminfo/data) and replace the entire existing code with what you just copied.
-
Save this module (Module:Iteminfo/data).
-
The database is now re-generated. It may take a bit until this is reflected on the individual articles; you can attempt to speed up the process by purging the cache of the respective articles.