Difference between revisions of "Reference variables"

Jump to navigation Jump to search
1,228 bytes removed ,  05:58, 14 August 2014
Moved page to ref variable, to avoid confusion since they may also store base forms
imported>Cipscis
(Fixing erroneous information about uninitialised reference variables)
imported>Odessa
(Moved page to ref variable, to avoid confusion since they may also store base forms)
 
Line 1: Line 1:
Like other variables, reference variables must be declared before they can be used:
#Redirect [[Ref Variable]]
 
<pre>
ref  refVarName 
</pre>
 
You can use a reference variable anywhere you could use an [[Reference|object reference]]. Uninitialized reference variables hold a value of 0, and will cause a script to silently stop running if used to call a [[Reference_functions|reference function]]; otherwise a reference variable acts just like any other reference.
 
You set reference variables using the set command, like other variables. Normally, you will want to use a [[:Category:Reference_Variable_Functions|reference variable function]], which returns a [[formID]]. For example:
<pre>
set myRef to GetContainer 
</pre>
 
Like other variables, you can set a reference variable on another scripted object:
 
<pre>
set BobRef.myRef to GetSelf 
</pre>
 
To check if a ref variable is unset:
<pre>
if myReferenceVariable == 0
</pre>
 
To check if a ref variable is set:
<pre>
if myReferenceVariable
</pre>
 
To check if a ref variable is another reference (in this example the player):
<pre>
if myReferenceVariable == player
</pre>
 
Or not another reference:
<pre>
if myReferenceVariable != player
</pre>
[[Category:Commands]]
[[Category:Scripting]]
[[Category:Variables]]
Anonymous user

Navigation menu