Template:Export cargo table

From Terraria Wiki
Jump to navigation Jump to search
This template uses Lua.
This template uses Module:Export cargo table, a script written in the Lua programming language. To learn more about Lua, see Terraria Wiki:Lua.
Template-info.svg Documentation The documentation below is transcluded from Template:Export cargo table/doc. (edit | history)

This template is used to generate the code for storing all the data of a cargo table (or certain parts of it) to another wiki, e.g. a language variant of the Terraria Wiki.

Usage

{{ export cargo table | _table = <cargo table name> | _fields = <cargo table fields> | _limit = <maximum rows> | _delimiter = <row separator> | _withdeclare = y/yes | <field parameters> }}

_table

Name of the table to export. See Special:CargoTables for a list of available cargo tables.

_fields

List of the table's fields that should be included in the export, comma-separated. Note that due to Lua's implementation of cargo queries, the order of rows may vary depending on the specified fields, which causes different rows to be displayed if $_limit is set. (However, it is guaranteed that all rows are displayed if $_limit is set to -1, even if their order might vary.)

_limit

Maximum number of rows that should be included in the export. Set this to -1 to include all rows. If omitted, defaults to the standard cargo query limit (generally 100).

_delimiter

String that separates the rows in the output. Defaults to a linebreak (<br/>).

_withdeclare

This parameter enables generation of the code for the declaration of the cargo table ({{#cargo_declare:}}). For that, it needs the information about the fields and their types, which should be passed as the remaining parameters. These can easily be copied from the table's declaration code.

Examples

The table used in the following example is the Items table, declared by Template:Item infobox.

Code Result
<div style="font-family: monospace;">
{{export cargo table
| _table = Items
| _fields = internalname, name, bodyslot, hardmode
| _limit = 5
| _withdeclare = y
| internalname = String | name = String
| bodyslot = String | hardmode = Boolean
}}
</div>

{{#cargo_declare:_table=Items|internalname=String|name=String|bodyslot=String|hardmode=Boolean}}

{{#cargo_store:_table=Items|internalname=AaronsBreastplate|name=Aaron's Breastplate|bodyslot=social shirt|hardmode=1}}
{{#cargo_store:_table=Items|internalname=AaronsHelmet|name=Aaron's Helmet|bodyslot=social helmet|hardmode=1}}
{{#cargo_store:_table=Items|internalname=AaronsLeggings|name=Aaron's Leggings|bodyslot=social pants|hardmode=1}}
{{#cargo_store:_table=Items|internalname=Abeemination|name=Abeemination}}
{{#cargo_store:_table=Items|internalname=AbigailsFlower|name=Abigail's Flower}}