模板:Source code ref
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
and $old
are set, then the template has no effect at all.
$onlycate
- 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
/etc. Has no effect if the first unnamed parameter is set.
$class
- First unnamed parameter
Generally, all relevant information should be provided in
/$method
/etc. and optionally $class
. However, it may be necessary to use an entirely custom text, in which case this parameter can be used. It overrides both $t
/$method
/etc. and $class
.
$t
- noref
Set to
/y
to suppress the yes
<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
is set.
$noref
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.
- This can be prevented with the
- 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 (.
), e.g. if a method/class/etc. should contain them. Examples:
Code Interpretation |method=Lorem.Ipsum.Dolor
method Dolor()
in fileLorem.Ipsum.cs
|method=Lorem.Ipsum.Dolor
method Ipsum.Dolor()
in fileLorem.cs
Examples
Code | Result |
---|---|
{{source code ref|v=1.4.4.9|noref=y}}
|
信息來自![]() |
{{source code ref|v=1.3.0.1|noref=y}}
|
信息來自![]() ![]() |
{{source code ref|v=1.2.4.1|old=y|noref=y}}
|
信息來自![]() |
{{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}}
|
信息來自![]() 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}}
|
信息來自![]() 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.Dolor / Bar.Bas|noref=y}}
|
信息來自![]() Bar.cs 中的 Foo() ,Lorem.cs 中的 Ipsum.Dolor() ,和 Bar.cs 中的 Bas() 方法。
|
{{source code ref|v=1.4.4.9|method=Bar.Foo / Lorem.Ipsum.Dolor / Bar.Bas|class=Sit.Amet / Consectetur.Adipiscing|field=Bar.Bax / Bar.Bay / Bar.Baz|noref=y}}
|
信息來自![]() Bar.cs 中的 Foo() ,Lorem.cs 中的 Ipsum.Dolor() ,和 Bar.cs 中的 Bas() 方法,Sit.cs 中的 Amet 和 Consectetur.cs 中的 Adipiscing 類,和 Bar.cs 中的 Bax ,Bar.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] |