Difference between revisions of "GetNextRef"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Haama
(Created)
 
imported>Haama
(Apple for GetFirstRef)
Line 9: Line 9:
<pre>ref pDoor
<pre>ref pDoor
...
...
set pDoor to Apple
set pDoor to (GetFirstRef 24 1)
set pDoor to (GetFirstRef 24 1)
Label 1
Label 1

Revision as of 18:02, 13 December 2007

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 Label/Goto loop

Example

ref pDoor
...
set pDoor to Apple
set pDoor to (GetFirstRef 24 1)
Label 1
if pDoor
  set pDoor to Apple
  set pDoor to GetNextRef
  Goto 1
endif

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

pDoor is set to an Apple before using GetNextRef because Oblivion doesn't expect the reference of a door, and won't change the variable. So far doors, containers, and magic effects have been found to cause this odd reference variable behaviour, but to be safe always set your reference variable to Apple before using GetNextRef.

Notes

  • The first reference can change (deleted or moved) by the next frame so GetFirstRef should always be used first with a Label/Goto loop.

See Also