Difference between revisions of "GetNextRef"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Scruggs
(Remove apple bug note as 1) it's not specific to GetNextRef and 2) it's fixed; Make example code use While loop)
imported>Nekhanimal
Line 17: Line 17:


==Notes==
==Notes==
*Although GetNextRef supplied with <type> and <celldepth>, like "GetNextRef 35 2" will compile and save, it will crash the script in-game.
*References can be added to or removed from a cell between frames; for this reason GetFirst/NextRef should be used within a loop that executes within a single frame.
*References can be added to or removed from a cell between frames; for this reason GetFirst/NextRef should be used within a loop that executes within a single frame.
* The order of references as returned by GetFirst/NextRef is essentially undefined. It is not guaranteed that it will remain the same from one frame to the next. As stated above, a loop should be used each time. ''Usually'', however, the first ref is the most recently placed one. It is altogether unwise to rely on this, however.
* The order of references as returned by GetFirst/NextRef is essentially undefined. It is not guaranteed that it will remain the same from one frame to the next. As stated above, a loop should be used each time. ''Usually'', however, the first ref is the most recently placed one. It is altogether unwise to rely on this, however.

Revision as of 19:17, 15 August 2010

A command for Oblivion Script Extender

Syntax:

(reference:ref) GetNextRef

Returns the next reference in the curent cell. GetFirstRef must be called first; this function uses the cell depth and type passed to GetFirstRef and returns the next reference matching that type, or zero after the last reference has been returned. This function should only be used within a loop.

Example

ref pDoor
...
set pDoor to GetFirstRef 24 1
while (pDoor)
  ; do something with pDoor
  set pDoor to GetNextRef
loop

Scans the list of doors in the player's current cell and the surrounding 8 cells.

Notes

  • Although GetNextRef supplied with <type> and <celldepth>, like "GetNextRef 35 2" will compile and save, it will crash the script in-game.
  • References can be added to or removed from a cell between frames; for this reason GetFirst/NextRef should be used within a loop that executes within a single frame.
  • The order of references as returned by GetFirst/NextRef is essentially undefined. It is not guaranteed that it will remain the same from one frame to the next. As stated above, a loop should be used each time. Usually, however, the first ref is the most recently placed one. It is altogether unwise to rely on this, however.

See Also