Difference between revisions of "GetSelf"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Cipscis
(Updated to use Function template; fixed bad example; added note about implicit reference syntax)
imported>Cipscis
(Changed syntax to show implicit reference syntax, as GetSelf should only ever be called implicitly; Added note about inventory items and GECK warning message, not too sure about how clear it is though)
Line 4: Line 4:
  |summary = Returns the RefID of the calling reference.  [[GetSelf]] is only useful when this information is accessed externally, or when the scripted reference's RefID needs to be passed as a parameter to a function like [[PushActorAway]]
  |summary = Returns the RefID of the calling reference.  [[GetSelf]] is only useful when this information is accessed externally, or when the scripted reference's RefID needs to be passed as a parameter to a function like [[PushActorAway]]
  |alias = this
  |alias = this
|referenceType = Reference
  |example = ref rSelf
  |example = ref rSelf
  set rSelf to GetSelf
  set rSelf to GetSelf
Line 18: Line 17:
Instead, just use code like this:
Instead, just use code like this:
<pre>ReferenceFunction</pre>
<pre>ReferenceFunction</pre>
</li>
<li>If [[GetSelf]] is called in a script that is attached to an inventory item, the GECK will show a warning message when the data file is loaded.  This warning can only be ignored if you can guarantee that the return value of [[GetSelf]] will not be used if it is called while the scripted item is in an inventory.  This is due to the fact that inventory items do not have regular RefIDs.  Rather, they are assigned RefIDs for the duration of a script execution so that reference functions may be called on them from their script, but these RefIDs are not permanent so attempting to use one of them will likely result in a script halt or other unintended behavior.
</li>
</li>
</ul>
</ul>

Revision as of 23:54, 23 October 2009

< [[::Category:Functions|Category:Functions]]

Link to TES4 Construction Set Wiki: GetSelf.

A function included in the GECK version 1.1.0.36.

Description

Returns the RefID of the calling reference. GetSelf is only useful when this information is accessed externally, or when the scripted reference's RefID needs to be passed as a parameter to a function like PushActorAway

Syntax

[help]
GetSelf 

Or:

this

Example

ref rSelf
set rSelf to GetSelf
player.PushActorAway rSelf 5

Notes

  • Because reference functions can be called on the scripted reference implicitly by omitting explicit reference syntax, the following code structure should never be used:
    ref rSelf
    set rSelf to GetSelf
    rSelf.ReferenceFunction

    Instead, just use code like this:

    ReferenceFunction
  • If GetSelf is called in a script that is attached to an inventory item, the GECK will show a warning message when the data file is loaded. This warning can only be ignored if you can guarantee that the return value of GetSelf will not be used if it is called while the scripted item is in an inventory. This is due to the fact that inventory items do not have regular RefIDs. Rather, they are assigned RefIDs for the duration of a script execution so that reference functions may be called on them from their script, but these RefIDs are not permanent so attempting to use one of them will likely result in a script halt or other unintended behavior.