Template:Callback: Difference between revisions
>Anaminus changing style; adding ''parameter'' and ''returns'' options |
>Anaminus Icon links to Callback |
||
Line 1: | Line 1: | ||
{{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"> | {{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"> | ||
{{{!}} cellspacing="0" cellpadding="4" style="margin: 2px; display: block; {{border-radius|6px}}; background: {{color|purple}}; font-size: 90%; text-align: left; border: 4px solid {{color|purple|dark}};" | {{{!}} cellspacing="0" cellpadding="4" style="margin: 2px; display: block; {{border-radius|6px}}; background: {{color|purple}}; font-size: 90%; text-align: left; border: 4px solid {{color|purple|dark}};" | ||
{{!}}style="padding: 1;font-size:120%; font-weight:bold;" colspan="2"{{!}}[[File:Callback Icon.png]] [[{{{name}}} (Callback)|{{{name}}}]] | {{!}}style="padding: 1;font-size:120%; font-weight:bold;" colspan="2"{{!}}[[File:Callback Icon.png|link=Callback]] [[{{{name}}} (Callback)|{{{name}}}]] | ||
{{!}}-style="background: {{color|purple|light}};" | {{!}}-style="background: {{color|purple|light}};" | ||
{{!}}style="width: 10%; border-top: solid 1px {{color|purple|dark}}; border-right: solid 1px {{color|purple|dark}}; font-weight:bold;"{{!}}Parameters: | {{!}}style="width: 10%; border-top: solid 1px {{color|purple|dark}}; border-right: solid 1px {{color|purple|dark}}; font-weight:bold;"{{!}}Parameters: |
Revision as of 07:58, 10 April 2012
[[{{{name}}} (Callback)|{{{name}}}]] | |
Parameters: | {{{parameters}}} |
Returns: | {{{returns}}} |
Description: | {{{description}}} |
Member of: |
This is a documentation subpage for Template:Callback.
It contains usage information, categories and other content that is not part of the original template page.
This template is used to document callbacks. It should only be used to document callbacks that are part of the ROBLOX API and should never be used to document functions, methods, or anything that isn't a callback.
Usage
<onlyinclude>{{Callback |name='''name''' |description='''description''' [|parameters='''parameters'''] [|returns='''returns'''] [|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.
Options
- name
- The name of the callback.
- parameters
- The values passed to the callback. See the section on parameters for more info on parameters.
- returns
- The types of the values that the callback function should return. 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 callback does not return anything.
- description
- A description of the callback.
- object
- The name of the object the callback belongs to, if there is only one. Otherwise, use the objects option.
- objects
- Links to the objects the callback belongs to, if there are more than one. Otherwise, use the object option.
Parameters
Parameters are formatted similarly to arguments in the Method Template. They 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 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 preferable, 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.
Callbacks
Callbacks are not exactly the same thing as methods, even though they share a similar icon. If you look closely at their icon and compare it to the icon of methods, you will notice some differences. Callbacks are used in the following way:
Object.Callback = function (param1)
return val1
end
In the code above, Object is an object, Callback is the name of a callback belonging to the object, and function is a function that will be set as the callback. param1 is the parameter passed to the function when it is called, and val1 is the value the function should return.
Notes
- If you need to put things after the callback, make sure to use the {{Clear floats}} template between the method and the rest of the page.
- All callbacks should be categorized under the Callbacks category.