Difference between revisions of "Reference Variables"

568 bytes removed ,  16:19, 24 May 2006
Clarified persistent-stuff, commented Jduvall's caveats and moved them to Discussion.
imported>Jduvall
imported>JOG
(Clarified persistent-stuff, commented Jduvall's caveats and moved them to Discussion.)
set myRef to GetContainer
</pre>
 
Like other variables, you can set a reference variable on another scripted object:
 
UserRef.Modactorvalue blade -50
end
Keep in mind, that References to non-persistent objects aren't accessible when the object is not in memory (i.e. in another cell) The same applies to inventory items that are currently within a container. Trying to access a non-accessible reference might have no effect at all, but it's equally probable that it will crash the game. While there are safeguards in the CS to prevent you from accessing such references directly, you can bypass them by using reference-variables.
 
Do so at your own risk...
CAVEAT: Objects created by leveled lists do not process in low, if you set a reference variable from a leveled list, if your script tries to refer to that reference variable when that actor isn't loaded, bad things will happen. So don't ever do a "set myRefVariable to myXmarker.placeAtMe myLeveledList". Instead create an if-then section in a script which checks the player level, pick an appropriate base object for the players level, then do a "set myRefVariable to myXmarker.placeAtMe SpecificBaseObjectID".
 
CAVEAT 2: You can not pass reference variables IN OTHER SCRIPTS as parameters to functions that take references. You must first set a local reference variable. For example: "myCharacterRef.look MyQuestScript.myReferenceVariable" will fail whereas "myCharacterRef.look myReferenceVariableDeclaredInThisScript" will work just fine. So in the local script just declare a "ref myReferenceVariableDeclaredInThisScript" and then set it to the external one "set myReferenceVariableDeclaredInThisScript to MyQuestScript.myReferenceVariable", and use the local one.
 
[[Category:Variables]]
Anonymous user