Template:Source code ref

From Terraria Wiki
Jump to navigation Jump to search
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 Documentation The documentation below is transcluded from Template:Source code ref/doc. (edit | history)

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}} Information taken from the Desktop version Desktop 1.4.4.9 source code.
{{source code ref|v=1.3.0.1|noref=y}} Information taken from the Desktop version Desktop 1.3.0.1 source code. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
{{source code ref|v=1.2.4.1|old=y|noref=y}} Information taken from the Desktop version Desktop 1.2.4.1 source code.
{{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}} Information taken from the Desktop version Desktop 1.4.4.9 source code, 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}} Information taken from the Desktop version Desktop 1.4.4.9 source code, method Foo() in Bar.cs. 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}} Information taken from the Desktop version Desktop 1.4.4.9 source code, methods Foo() in Bar.cs, Ipsum.Dolor() in Lorem.cs, and Bas() in Bar.cs.
{{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}} Information taken from the Desktop version Desktop 1.4.4.9 source code, methods Foo() in Bar.cs, Ipsum.Dolor() in Lorem.cs, and Bas() in Bar.cs, classes Amet in Sit.cs and Adipiscing in Consectetur.cs, and fields Bax in Bar.cs, Bay in Bar.cs, and Baz in Bar.cs.
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. Information taken from the Desktop version Desktop 1.3.0.1 source code, method Foo() in Bar.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.