Morrowind Mod:XNextRef

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

A function added by MWSE.

xNextRef returns the next reference in one of the three lists of objects in the current cell (NPC, Item, and Static) after the current one. If the player is outside, the list will cycle through all 9 loaded exterior cells which may be too much to do in a single frame. Object references added by mods will be returned only if they are persistent.

In v0.9.4a this function is bugged: it may not return all references in exterior cells, and it returns deleted references. These bugs are fixed in the MWSE update released by Merzasphor.

Syntax[edit]

reference (long): xNextRef current (reference, long)

Example[edit]

long NPCref

ifx ( NPCref )
        setx NPCref to xNextRef NPCref
else
        setx NPCref to xFirstNPC
endif
if ( NPCref == 0 )
        messagebox "NPC search done"
endif   

Here we are using xFirstNPC to retrieve the first NPC in the list of the current cells, but xFirstItem and xFirstStatic could also be used for items and statics respectively. Then we are using our current reference (stored in NPCref) as a parameter for xNextRef so that the function will know from where to pick the next reference in the list. This new reference (in this case it's the second one in the list) is then set to NPCref.

See Also[edit]

xSetRef
xRefType
xGetRef
xGetCombat
xGetPCTarget