FindAllReferencesWithKeyword - ObjectReference

Member of: ObjectReference Script

Finds all references with any required keywords in the loaded area within the given radius of the calling ref.

SyntaxEdit

ObjectReference[] Function FindAllReferencesWithKeyword(Form arKeywordOrList, float afRadius) native

ParametersEdit

  • arKeywordOrList: Keyword to look for or form list of keywords which ref must have all of
  • afRadius: Maximum distance from ref to look for a reference

Return ValueEdit

An array of references with the required keywords within the radius, empty if none was found.

ExamplesEdit

; Find all references with the ActorTypeAnimal keyword within 200 distance units of the player
ObjectReference[] kActorArray = Game.GetPlayer().FindAllReferencesWithKeyword(ActorTypeAnimal, 200.0)

; Find all references that match ALL keywords in the actor type formlist within 200 distance units of the player
ObjectReference[] kActorArray = Game.GetPlayer().FindAllReferencesWithKeyword(ActorTypeFormlist, 200.0)

; Find all references that match ANY keyword in the actor type formlist within 200 distance units of the player
Int i = 0
While i < ActorTypeFormlist.GetSize()
    ObjectReference[] kActorArray = Game.GetPlayer().FindAllReferencesWithKeyword(ActorTypeFormlist.GetAt(i), 200.0)
    i += 1
EndWhile

NotesEdit

  • If wanting to grab all actors in the loaded area using the keywords, ActorTypeNPC or ActorTypeHuman, the player will also be added to the array as its race contains both of those keywords. If having the player be in the array is not intended, you can remove it via Find - Array and then Remove - Array:
Actor Player = Game.GetPlayer()
ObjectReference[] kActors = Player.FindAllReferencesWithKeyword(ActorTypeNPC, 2048.0)

int playerIndex = kActors.Find(Player as Actor)
kActors.Remove(playerIndex)

See AlsoEdit