Difference between revisions of "Help:Function syntax"

1,062 bytes added ,  01:21, 5 January 2012
m
moved Function syntax to Help:Function syntax: it's a help page, belongs in the Help namespace.
imported>DragoonWraith
(about OBSE's reference-or-object syntax)
imported>DragoonWraith
m (moved Function syntax to Help:Function syntax: it's a help page, belongs in the Help namespace.)
 
(6 intermediate revisions by the same user not shown)
Line 15: Line 15:
=== Return Value ===
=== Return Value ===


The first part of this format details what the function returns; this value may be stored in an appropriate [[:Category:Variables|variable]] or used as a condition in an <tt>if</tt> statement or similar. If the function does not return any value, <tt>(void)</tt> is used; otherwise, the return value is split into two halves, separated by a colon (<tt>:</tt>). The first half is what the value signifies (often a game statistic, sometimes other things), while the second half is the type of the value:
The first part of this format details what the function returns; this value may be stored in an appropriate [[:Category:Variables|variable]] or used as a condition in an <tt>if</tt> statement or similar. If the function does not return any value, <tt>(nothing)</tt> or <tt>(void)</tt> is used; otherwise, the return value is split into two halves, separated by a colon (<tt>:</tt>). The first half is what the value signifies (often a game statistic, sometimes other things), while the second half is the type of the value:
* <tt>short</tt> for integers
* <tt>short</tt> for integers.
* <tt>float</tt> for numbers that may include decimals
* <tt>float</tt> for numbers that may include decimals.
* <tt>string</tt> for text
* <tt>string</tt> for text — note that Oblivion did not originally return strings, having no <tt>string</tt> variable type, but several functions use arguments of this type (see below). [[:Category:Oblivion Script Extender|OBSE]] adds a <tt>string</tt> variable type as well as functions that return strings.
* <tt>bool</tt> for true/false values
* <tt>bool</tt> for true/false values — note that Oblivion does not support specific <tt>bool</tt> type variables, but rather just uses any numerical type (usually a <tt>short</tt>) for these: if the value is <tt>true</tt>, the number will be non-zero (usually but not necessarily <tt>1</tt>), while if the value is <tt>false</tt>, the number will be zero.
* <tt>ref</tt> for formIDs (stored in a [[Reference Variables|<tt>ref</tt> variable]])
* <tt>ref</tt> for formIDs — these are stored in a [[Reference Variables|<tt>ref</tt> variable]].
In addition, [[:Category:Oblivion Script Extender|OBSE]] adds some other types.
In addition, [[:Category:Oblivion Script Extender|OBSE]] adds some other types.


Line 28: Line 28:


This section is ''italicized'' if the reference is optional. However, this indicates whether or not the function requires a reference, which is '''not''' the same as whether or not you must use the <tt>reference.</tt> syntax. This is because many scripts (such as Object scripts in certain cases, or all Magic scripts) have a '''default reference''' which is used if none is supplied through the <tt>reference.</tt> syntax. However, if a function requires a reference (it is not ''italicized'' in the syntax description), then you must ''always'' use one in a Quest script (as they do not have default references). If it is ''italicized'', then it is completely optional and you need not include it even in a Quest script (though you may need to in order to get it to do what you want).
This section is ''italicized'' if the reference is optional. However, this indicates whether or not the function requires a reference, which is '''not''' the same as whether or not you must use the <tt>reference.</tt> syntax. This is because many scripts (such as Object scripts in certain cases, or all Magic scripts) have a '''default reference''' which is used if none is supplied through the <tt>reference.</tt> syntax. However, if a function requires a reference (it is not ''italicized'' in the syntax description), then you must ''always'' use one in a Quest script (as they do not have default references). If it is ''italicized'', then it is completely optional and you need not include it even in a Quest script (though you may need to in order to get it to do what you want).
===== Reference or Object =====


Of special interest is a rather-common scheme used by OBSE:
Of special interest is a rather-common scheme used by OBSE:
  (return) ''reference.''FunctionName ''baseObject:ref''
  (return) ''reference.''FunctionName ... ''baseObject:ref''
where the <tt>''baseObject:ref''</tt> is the last argument (see [[#Arguments|Arguments]], below). In this case, the function takes ''either'' a reference ''or'' a base object; if you use a reference, the function will find and operate on the function's base object, but otherwise it will just change the base object. Functions that change the base object '''will change every reference to that object'''. See also [[Modding Terminology]].
where the <tt>''baseObject:ref''</tt> is the last argument (see [[#Arguments|Arguments]], below). In this case, the function takes ''either'' a reference ''or'' a base object; if you use a reference, the function will find and operate on the reference's base object, but otherwise it will just change the base object. Functions that change the base object '''will change every reference to that object'''. See also [[Modding Terminology]].


=== Function Name and Aliases ===
=== Function Name and Aliases ===
Line 60: Line 62:


This section lists similar functions which may be relevant to someone using the given function.
This section lists similar functions which may be relevant to someone using the given function.
== Categories ==
Each function is categorized into one or more categories. These can allow you to find functions that deal with similar objects (such as actors or quest stages), limit the lists of functions that you're looking at to certain versions of the CS or with or without OBSE, etc. The categories at the bottom of the page can be extremely helpful in navigating the Wiki!


[[Category:Scripting]]
[[Category:Scripting]]