Difference between revisions of "FindAllReferencesWithKeyword - ObjectReference"

→‎Notes: Found easier non pulling method to remove the player from the array.
imported>Scrivener07
(Player is added to the array if the passed in keywords matches that of the keywords of the player.)
imported>Scrivener07
(→‎Notes: Found easier non pulling method to remove the player from the array.)
 
(One intermediate revision by the same user not shown)
Line 33: Line 33:
</source>
</source>
== Notes ==
== Notes ==
* 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 need can remove it by checking for its formID of 20(decimal).
* 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]]:
<source lang="papyrus">
<source lang="papyrus">
int index = actorArray.Length
Actor Player = Game.GetPlayer()
ObjectReference[] kActors = Player.FindAllReferencesWithKeyword(ActorTypeNPC, 2048.0)


while index
int playerIndex = kActors.Find(Player as Actor)
    index -= 1
kActors.Remove(playerIndex)
    if actorArray[index].GetFormID() == 20
        actorArray.Remove(index)
    endif
endWhile
</source>
</source>


Anonymous user