Difference between revisions of "GetSelf"

1,620 bytes added ,  07:38, 15 May 2011
Added a note on a GetSelf glitch
imported>Scruggs
(clarified usage with carriable objects; unreliable when called on player)
imported>QQuix
(Added a note on a GetSelf glitch)
 
(20 intermediate revisions by 9 users not shown)
Line 8: Line 8:
  set MyQuest.targetRef to GetSelf
  set MyQuest.targetRef to GetSelf


Returns the calling object itself as a reference. Useful for if statements, or for setting reference variables on other scripts.
An alias for [[This]]. Returns the calling object itself as a reference. Useful for if statements, or for setting reference variables on other scripts.




Notes:
==Notes==
* When this function is called on a carriable object (such as a weapon or miscellaneous item), the reference returned only remains valid while the object remains in the gameworld.
* This function doesn't work quite as expected for [[Glossary#I|item]]s. See [http://www.uesp.net/wiki/Tes4Mod:Modding_Terminology Modding Terminology], especially the [http://www.uesp.net/wiki/Tes4Mod:Modding_Terminology#Dynamic_Items Dynamic Items] and [http://www.uesp.net/wiki/Tes4Mod:Modding_Terminology#Scripting_Notes Scripting Notes] sections for more information. In particular :
* This function appears to be unreliable when called on the player.
** GetSelf applied to a mod based (non-dynamic) item will always return the original formid of the item as long as the item is in the world (not in an inventory).
** getSelf applied to a dynamic item will always return 0 -- even when the item is in a cell and has a reference. While you might expect it to return the formid of its dynamic reference while in the cell, apparently the function is rigged to return zero for safety reasons. Directly contrary to the behavior of getSelf, [[placeAtMe]] creates a dynamic reference -- ''and'' returns the correct formid.
 
*GetSelf returns 0 if the item is in an inventory (for both, dynamic and non-dynamic items)
 
* This function [[Talk:GetSelf#Unreliability with Player|appears to be unreliable]] when called on the player.
**You can use
<pre>set ref to GetSelf
if (ref.GetIsReference player == 0)</pre>
to make sure it's not the player. See the talk page for more information.
* This function returns 0 when called on a [[Light]].
* If used (1) in an item script AND (2) the item is in a container in an exterior cell AND (3) the container cell is loaded as the player approaches on foot AND (4) GetSelf is used in the very first frame >> the game CTDs. ([[Talk:GetSelf#GetSelf glitch|see the talk page for details]])
 
==See Also==
[[This]]


[[Category: Functions]]
[[Category: Functions]]
[[Category: Reference Variable Functions]]
[[Category: Functions (CS)]]
[[Category: Functions (CS 1.0)]]
[[Category: Record Variable Functions]]
[[Category: Record Variable Functions (CS 1.0)]]
 
<!-- Begin Search Terms
Get
Self
 
End Search Terms -->
Anonymous user