Template:Source code ref

来自Terraria Wiki
跳到导航 跳到搜索
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for templates to learn more.
See Template:Source code ref/l10n for the localization of this template.
Template-info.svg 文档 以下文档来自Template:Source code ref/doc。(编辑 | 历史

This template can be used to mark information as being taken from Terraria's source code. It prints a short, modifiable text wrapped in a <ref> tag.

Usage

{{source code ref | v = <source code version> | old = y/yes | onlycate = y/yes | method/class/struct/field/property/event/constant = <method/etc. name(s)> | t = <further comments> | <custom text> | noref = y/yes | name = <custom <ref> name> }}

v

Set it to the version of Terraria from which the information was taken. This is important because the game and source code change over time, and it helps identifying potentially outdated information in future updates.

old

Setting this parameter signifies that the information is intentionally taken from an outdated version of Terraria's source code, e.g. for historical pieces of trivia.

onlycate

Suppresses all textual output and only categorizes the page, if necessary (see notes). This is useful to track the "up-to-dateness" of pieces of information that are not visible in the article text. If both $old and $onlycate are set, then the template has no effect at all.

method, class, struct, field, property, event, constant

If there is a specific method, class, struct, field, property, event, or constant that the information was taken from, its name (including full namespace) can be passed to this parameter. This is useful for an automatic, standardized formatting and localization. Multiple of these parameters can be used together, and each one can hold multiple names, separated by a slash (/). None of these parameters has any effect if the first unnamed parameter is set.

t

Can be used to add further comments to the information passed in $method/$class/etc. Has no effect if the first unnamed parameter is set.

First unnamed parameter

Generally, all relevant information should be provided in $method/$class/etc. and optionally $t. However, it may be necessary to use an entirely custom text, in which case this parameter can be used. It overrides both $method/$class/etc. and $t.

noref

Set to y/yes to suppress the <ref> tag.

name

Can be used to specify a custom name for the <ref>, so that a <ref> can be reused several times (via <ref name="<name>" />). Has no effect if $noref is set.

Notes

  • Although all parameters are optional, $v should always be set.
  • If the version passed in $v is different from the current Desktop version (determined via {{version|desktop}}), a note will be appended. The page will furthermore be categorized in Category:Pages with information based on outdated versions of Terraria's source code.
    • This can be prevented with the $old parameter.
  • If there is at least one call of {{source code ref}} without $noref on the page, a new section "References" or "Footnotes" with {{reflist}} needs to be added.
  • For each method/class/etc. provided, the template considers everything in front of the last period to be the file name (without the .cs extension, which it appends). To prevent this, escape periods with the HTML entity (&#46;), e.g. if a method/class/etc. should contain them. Examples:
Code Interpretation
|method=Lorem.Ipsum.Dolor method Dolor() in file Lorem.Ipsum.cs
|method=Lorem.Ipsum&#46;Dolor method Ipsum.Dolor() in file Lorem.cs

Examples

Code Result
{{source code ref|v=1.4.4.9|noref=y}} 信息来自电脑版 电脑版 1.4.4.9 源代码。
{{source code ref|v=1.3.0.1|noref=y}} 信息来自电脑版 电脑版 1.3.0.1 源代码。这可能已经不准确,因为电脑版 电脑版的当前版本已经是 1.4.4.9。
{{source code ref|v=1.2.4.1|old=y|noref=y}} 信息来自电脑版 电脑版 1.2.4.1 源代码。
{{source code ref|v=1.4.4.9|the <code>Misc.LicenseSlimeUsed</code> key in the localization file <code>Terraria.Localization.Content.en-US.json</code>.|noref=y}} 信息来自电脑版 电脑版 1.4.4.9 源代码,the Misc.LicenseSlimeUsed key in the localization file Terraria.Localization.Content.en-US.json.
{{source code ref|v=1.4.4.9|method=Bar.Foo|t=The first <code>if-else</code> block in the method shows that ...|noref=y}} 信息来自电脑版 电脑版 1.4.4.9 源代码,Bar.cs 中的 Foo() 方法。The first if-else block in the method shows that ...
{{source code ref|v=1.4.4.9|method=Bar.Foo / Lorem.Ipsum&#46;Dolor / Bar.Bas|noref=y}} 信息来自电脑版 电脑版 1.4.4.9 源代码,Bar.cs 中的 Foo()Lorem.cs 中的 Ipsum.Dolor(),和 Bar.cs 中的 Bas() 方法。
{{source code ref|v=1.4.4.9|method=Bar.Foo / Lorem.Ipsum&#46;Dolor / Bar.Bas|class=Sit.Amet / Consectetur.Adipiscing|field=Bar.Bax / Bar.Bay / Bar.Baz|noref=y}} 信息来自电脑版 电脑版 1.4.4.9 源代码,Bar.cs 中的 Foo()Lorem.cs 中的 Ipsum.Dolor(),和 Bar.cs 中的 Bas() 方法,Sit.cs 中的 AmetConsectetur.cs 中的 Adipiscing 类,和 Bar.cs 中的 BaxBar.cs 中的 Bay,和 Bar.cs 中的 Baz 字段。
The thing takes three seconds to be done in Classic Mode and six seconds in Expert Mode.{{source code ref|v=1.3.0.1|method=Bar.Foo}} The thing takes three seconds to be done in Classic Mode and six seconds in Expert Mode.[1]

References

  1. 信息来自电脑版 电脑版 1.3.0.1 源代码,Bar.cs 中的 Foo() 方法。这可能已经不准确,因为电脑版 电脑版的当前版本已经是 1.4.4.9。