Difference between revisions of "Help:Function syntax"

38 bytes added ,  08:56, 1 September 2011
imported>DragoonWraith
(about OBSE's reference-or-object syntax)
imported>DragoonWraith
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 ===