注意:1.4.5 的更新内容量较大,页面上很可能仍有内容尚未更新。
如中文 wiki 信息过时,可以参考英文 wiki 对应页面。
Terraria Wiki:项目/1.4.5 获取 wiki 状态与更新指南

Template:Iteminfo query

来自Terraria Wiki
跳转到导航 跳转到搜索
此模板使用了 Lua。
此模板使用了用 Lua 编程语言编写的 模块:Iteminfo query。要了解 Lua 的更多信息,参见 en:Terraria Wiki:Lua
Important.svg
CAUTION: Terraria Wiki code is complex!!!
If you want to use this code on another wiki, wiki.gg staff are not able to assist you.
Please consider picking a different wiki to adapt code from, or making your own templates!
Remember that content on a wiki is more important than fancy formatting.
Template-info.svg 文档 以下文档来自Template:Iteminfo query/doc。(编辑 | 历史

This template is used for querying the iteminfo database. This is useful for obtaining information that is not available in the Items cargo table.

Usage

{{ iteminfo query | stat = <statistic> | value = <stat value> | valuenot = <stat value> | get = count/name/id | sort = name/id }}

stat, value, valuenot

Parameters for the query. The template fetches all items whose $stat value is equal to $value. For instance, with |stat=noMelee|value=true it finds all items that have a noMelee value of true. Alternatively, $valuenot allows searching for items whose $stat value is not equal to the specified value. Only one out of $value and $valuenot can be used, not both. See Module:Iteminfo for a list of all available stats and possible values.

get

Format of the output of the items that match the condition: either the number of items (|get=count), a list of English item names (|get=name; this is the default), or a list of item IDs (|get=id). Lists are returned as arrays from Extension:ArrayFunctions, which can be further processed with the extension's parser functions, such as {{#af_foreach:}}.

sort

Order of the item list. Items are sorted either by name (|sort=name) or by item ID (|sort=id; this is the default). This parameter has no effect if |get=count is used. On language wikis, item names are sorted in the local language, even though the output (with |get=name) is in English. This facilitates passing the item names to {{item}}, which expects English names as input and translates them itself.

Examples

Code Result
{{iteminfo query|stat=noMelee|value=true|get=count}} 675
{{iteminfo query|stat=sacrifices|valuenot=0|get=count}} 6087
{{#af_print:{{iteminfo query|stat=stringColor|valuenot=false}}}}
  • 1: Red String
  • 2: Orange String
  • 3: Yellow String
  • 4: Lime String
  • 5: Green String
  • 6: Teal String
  • 7: Cyan String
  • 8: Sky Blue String
  • 9: Blue String
  • 10: Purple String
  • 11: Violet String
  • 12: Pink String
  • 13: Brown String
  • 14: White String
  • 15: Rainbow String
  • 16: Black String
  • 17: Strung Counterweight
{{#af_print:{{iteminfo query|stat=useAmmo|value=283}}}}
  • 1: Blowpipe
  • 2: Blowgun
  • 3: Dart Pistol
  • 4: Dart Rifle
{{#af_join:{{iteminfo query|stat=useAmmo|value=283|get=id}}}} 281, 986, 3007, 3008
{{options/set|itemlist|width=12em}}
{{#af_template:itemlist|
{{#af_map:
{{iteminfo query|stat=useAmmo|value=283|get=id|sort=name}}
|id|
{{item|id={{#af_show:{{{id}}}}}}}
}}}}
{{options/reset|itemlist}}