Difference between revisions of "Help:Function syntax"
→Return Value: some clarification; seems a bit over-long, though.
imported>DragoonWraith |
imported>DragoonWraith (→Return Value: some clarification; seems a bit over-long, though.) |
||
Line 16: | Line 16: | ||
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>(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> type as well as functions that return strings. | ||
* <tt>bool</tt> for true/false values — note that Oblivion does not support specific <tt>bool</tt> 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>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 | * <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. | ||