Difference between revisions of "GetSelf"
Jump to navigation
Jump to search
m
Reversed the example in notes. "never do this" was and still is bad advice.
imported>Cipscis (Further testing of GetSelf reveals that it returns 0 when called on references saved in the save game (i.e. those with formIDs starting with "ff"). Thanks to HugePinball for pointing this out.) |
imported>Prideslayer m (Reversed the example in notes. "never do this" was and still is bad advice.) |
||
Line 11: | Line 11: | ||
==Notes== | ==Notes== | ||
<ul> | <ul> | ||
<li> | <li>While functions that take an implied reference can be cast without needing a variable or call to getself, like so: | ||
<pre>ref rSelf | <pre>CIOS someSpell</pre> | ||
Doing so may not be clear, and makes the code less portable if moved to a different script that does not support the implied reference. For this reason, modders should prefer the more expressive syntax: | |||
<pre> | |||
ref rSelf | |||
set rSelf to GetSelf | set rSelf to GetSelf | ||
rSelf. | rSelf.CIOS someSpell</pre> | ||
Not only for CIOS, but for all "reference methods" that require a reference, like CIOS. | |||
</li> | </li> | ||
<li>[[GetSelf]] will return 0 if called on a reference that has been created dynamically (for example, created via [[PlaceAtMe]], or dropped from an inventory into the game world). | <li>[[GetSelf]] will return 0 if called on a reference that has been created dynamically (for example, created via [[PlaceAtMe]], or dropped from an inventory into the game world). |