Get a List of all Object References of a specific Form Type in the current Cell with Papyrus
Following protip is for the Scripting language Papyrus, used to mod the game Skyrim.
Here is a small code example, on how to get a List of all Object References of a specific Form Type in the current Cell with Papyrus:
Cell kCell = Self.GetParentCell()
Int iIndex = kCell.GetNumRefs(formTypeToGet)
ObjectReference[] objectReferencesList = new ObjectReference[100]
while (iIndex)
iIndex -= 1
objectReferencesList[iIndex] = kCell.GetNthRef(iIndex, formTypeToGet)
endwhile
Needs SKSE to work
This is useful for example if you need to dynamically access all NPCs in a Cell, without hard-coding a list into Papyrus or Creation Kit.
Written by Ritchie Flick
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Skyrim
Authors
Related Tags
#skyrim
#list
#papyrus
#skse
#object reference
#form type
#cell
#list of object references
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#