Template:Callback: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens
No edit summary
>JulienDethurens
I said I'd document all the object templates, even if that's a lot of work. That includes callbacks, even if there are only 2 callbacks in the whole ROBLOX API...
Line 1: Line 1:
<div style="float:left; max-width:600px; width: 50%; min-height:120px; overflow:auto">
<div style="float:left; max-width:600px; width: 50%; min-height:120px; overflow:auto">
{| cellspacing="0" cellpadding="4" style="margin: 4px; padding: 4px; display: block; {{border-radius|6px}}; background: #ffdddd; font-size: 90%; text-align: left; border: 4px solid #B57EDC;"
{| cellspacing="0" cellpadding="4" style="margin: 4px; padding: 4px; display: block; {{border-radius|6px}}; background: #ffdddd; font-size: 90%; text-align: left; border: 4px solid #B57EDC;"
|style="padding: 1;font-size:120%; font-weight:bold;" colspan="2"|[[Image:Callback icon.png]] [[{{{name}}} (Callback)|{{{name}}}]]
|style="padding: 1;font-size:120%; font-weight:bold;" colspan="2"|[[File:Callback icon.png]] [[{{{name}}} (Callback)|{{{name}}}]]( {{{arguments<includeonly>|</includeonly>}}} )
|-style="background: #ffdddd;"
|-style="background: #ffdddd;"
|style="width: 10%; border-top: solid 1px black; border-right: solid 1px black; font-weight:bold;"|Description:  
|style="width: 10%; border-top: solid 1px black; border-right: solid 1px black; font-weight:bold;"|Description:  
|style="border-top: solid 1px black;"|{{{description}}}
|style="border-top: solid 1px black;"|{{{description}}}
|-style="background: #FFFFFF;"
|-style="background: #FFFFFF;"
|style="width: 10%; border-top: solid 1px black; border-right: solid 1px black; font-weight:bold;"|In Object{{if|{{{object2|}}}|s}}:
|style="width: 10%; border-top: solid 1px black; border-right: solid 1px black; font-weight:bold;"|Member of
|style="border-top: solid 1px black;"|{{if|{{{object|}}}|{{type|instance={{{object|}}}}}}}{{if|{{{objects|}}}|{{{objects|}}}}}
|style="border-top: solid 1px black;"|{{if|{{{object|}}}|{{type|instance={{{object|}}}}}}}{{if|{{{objects|}}}|{{{objects|}}}}}
|}</div><noinclude>{{clear floats}}
|}</div><noinclude>{{documentation}}</noinclude>
== Example Usage ==
 
=== Single Object ===
<pre>
{{Callback
|name        = Receive
|description = The function that is called by [[CustomEvent]]:[[Raise]]
|object      = CustomEventReceiver
}}
</pre>
 
=== Multiple Objects ===
<pre>
{{Callback
|name        = asdf
|description = ghjkl;
|objects    = {{type|instance=Model}}, {{type|instance=Part}}, {{type|instance=Weld}}
}}
</pre>
[[Category:Object Documentation Templates]]
</noinclude>

Revision as of 19:14, 9 April 2012

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

Documentation subpage icon

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

Main article: Callback (Tutorial)

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.