Template:Method: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>ArceusInator
I hope I didn't just break that
>JulienDethurens
Categorizing pages with errors so we can fix them easily! :D
 
(66 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<includeonly><div class="object-data" style="background-color: {{color|red|light}}; border: 1px solid {{color|red|dark}}; {{border-radius|5.5px}}; overflow:hidden; margin: 4px;{{{2|}}}"><div class="object-data-header" style="{{border-top-radius|4.5px}}; padding: 4px;  background-color: {{color|red|medium}}"><div class="img" style="float: left; margin-right: 4px;">
{{if|1={{{name<includeonly>|</includeonly>}}}|2={{if|1={{{description<includeonly>|</includeonly>}}}|2=<div style="float:left; max-width:600px; width: 50%; min-height:120px; overflow:auto">
</div>
{{{!}} cellspacing="0" cellpadding="4" style="margin: 2px; display: block; {{border-radius|6px}}; background: {{color|magenta}}; font-size: 90%; text-align: left; border: 4px solid {{color|magenta|dark}};"
<div style="font-size: 75%;text-align: right;color: {{Color|blue|dark}};">'''Member of:'''
{{!}}style="padding: 1;font-size:120%; font-weight:bold;" colspan="2"{{!}}[[File:{{if|{{{protected|}}}|Protected_}}Method Icon.png]] [[{{{name}}} (Method)|{{{name}}}]]( {{{arguments<includeonly>|</includeonly>}}} )
{{if|{{{object|}}}|[[{{{object|}}}]]}}{{if|{{{objects|}}}|{{{objects|}}}}}</div>[[Image:{{if|{{{protected|}}}|Protected}}Method Icon.png]][[{{{name}}} (Method)|{{{name}}}]] ({{{arguments|}}})
{{!}}-style="background: {{color|magenta|light}};"
</div>
{{!}}style="width: 10%; border-top: solid 1px {{color|magenta|dark}}; border-right: solid 1px {{color|magenta|dark}}; font-weight:bold;"{{!}}Returns
<div class="Pcontainer" style="{{border-top: 1px solid {{color|red|dark}}}}; padding: 4px; background-color:{{color|blue|light}}">'''Returns:'''        {{{returns}}}</div>
{{!}}style="border-top: solid 1px {{color|magenta|dark}};"{{!}}{{{returns<includeonly>|{{nil}}</includeonly>}}}
<div class="Dcontainer" style="{{border-top: 1px solid {{color|red|dark}}}}; padding: 4px; background-color:{{color|blue|light}}">'''Description:'''  {{{description}}}</div></div></includeonly>
{{!}}-
== Example Usage ==
{{!}}style="width: 10%; border-top: solid 1px {{color|magenta|dark}}; border-right: solid 1px {{color|magenta|dark}}; font-weight:bold;"{{!}}Description:
 
{{!}}style="border-top: solid 1px {{color|magenta|dark}};"{{!}}{{{description}}}
=== Single Object ===
{{!}}-style="background: {{color|magenta|light}};"
<pre>
{{!}}style="width: 10%; border-top: solid 1px {{color|magenta|dark}}; border-right: solid 1px {{color|magenta|dark}}; font-weight:bold;"{{!}}Member of:
{{Method
{{!}}style="border-top: solid 1px {{color|magenta|dark}};"{{!}}{{if|{{{object|}}}|{{type|instance={{{object|}}}}}|{{if|{{{objects|}}}|{{{objects|}}}}}}}
|name        = FindFirstChild
{{!}}}</div>|3=<p class="error">The description must be specified.</p>[[Category:Pages with template errors]]}}|3=<p class="error">The name must be specified.</p>[[Category:Pages with template errors]]}}<noinclude>{{documentation}}[[Category:Object Documentation Templates]]</noinclude>
|arguments  = [[String]] Name
|returns    = [[Instance]] ''object''
|description = Returns the first child found with a name of ''Name''.
|object     = Instance
}}
</pre>
 
=== Multiple Objects ===
<pre>
{{Method
|name        = BreakJoints
|description = Breaks any Surface connections with any adjacent parts, including [[Weld]]s and other [[JointInstance]]s.
|objects    = [[Model]], [[Part]], [[Weld]]
}}
</pre>
[[Category:Object Documentation Templates]]
</noinclude>

Latest revision as of 07:11, 10 April 2012

[[{{{name}}} (Method)|{{{name}}}]]( {{{arguments}}} )
Returns {{{returns}}}
Description: {{{description}}}
Member of:
[purge] Template documentation

Documentation subpage icon

This is a documentation subpage for Template:Method.
It contains usage information, categories and other content that is not part of the original template page.

This template is used to document methods. It should only be used to document methods that are part of the ROBLOX API and should never be used to document functions or anything that isn't a method.

Usage

<onlyinclude>{{Method
|name=name
|description=description
[|arguments=arguments]
[|returns=types]
[|protected=bool]
[|object=object]
[|objects=objects]
}}</onlyinclude>

Note: text between brackets ([ and ]) is optional, text in bold represents a certain value (something you must replace) and the rest represents things that must be present as-is.

Parameters

name
The name of the method.
arguments
The arguments received by the method. See the section on arguments for more info on arguments.
returns
The types of the values returned by the function. Do not give them a name, only give their type. If they can be confusing, explain them in the description. If this argument is not specified, it will be indicated that the method does not return anything.
description
A description of the method.
protected
If specified, the icon of the method will indicate that the method is protected.
object
The name of the object this method belongs to, if there is only one. Otherwise, use the objects argument.
objects
Links to the objects this method belongs to, if there are more than one. Otherwise, use the object argument.

Arguments

Arguments should be separated by commas. Their type should always be written before their name and should always be identical to the one written in the object browser, the only exception being if the error messages given by the method specify a more specific type. The type should either be in raw text, either be a link to the page of the type or either be displayed with the {{type}} template. The name should always either be contained in a <var> tag, which is preferrable, either be italicized with wiki markup.

Default values for arguments should be indicated outside of the <var> or outside of the italicization and be indicated the same way as they are in the object browser.

Notes

  • The method should always be at the top of the page.
  • If you need to put things after the method, make sure to use the {{clear floats}} template between the method and the rest of the page.
  • All methods should be categorized under the Methods category.

Example

This is an example of an use of this template with the FindFirstChild method:

{{Method
|name        = FindFirstChild
|arguments   = {{Type|string}} <var>name</var>, {{Type|bool}} <var>recursive</var> = false
|returns     = {{Type|instance=Instance}}
|description = Returns the first child of this Instance that matches the first argument <var>name</var>. The second argument <var>recursive</var> is an optional boolean (defaults to {{false}}) that will force the call to traverse down thru all of this Instance's descendants until it finds an object with a name that matches the <var>name</var> argument. The function will return {{nil}} if no Instance is found.
|object      = Instance
}}

Here is the result it would produce:

FindFirstChild( string name, bool recursive = false )
Returns Instance
Description: Returns the first child of this Instance that matches the first argument name. The second argument recursive is an optional boolean (defaults to false) that will force the call to traverse down thru all of this Instance's descendants until it finds an object with a name that matches the name argument. The function will return nil if no Instance is found.
Member of: Instance