Difference between revisions of "FindAllReferencesWithKeyword - ObjectReference"
FindAllReferencesWithKeyword - ObjectReference (edit)
Revision as of 11:25, 4 February 2021
, 11:25, 4 February 2021→Notes: Found easier non pulling method to remove the player from the array.
imported>Gawdl3y |
imported>Scrivener07 (→Notes: Found easier non pulling method to remove the player from the array.) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 19: | Line 19: | ||
== Examples == | == Examples == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
; Find all | ; Find all references with the ActorTypeAnimal keyword within 200 distance units of the player | ||
ObjectReference[] | ObjectReference[] kActorArray = Game.GetPlayer().FindAllReferencesWithKeyword(ActorTypeAnimal, 200.0) | ||
; Find all | ; Find all references that match ALL keywords in the actor type formlist within 200 distance units of the player | ||
ObjectReference[] | 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 | |||
</source> | |||
== 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 can remove it via [[Find - Array]] and then [[Remove - Array]]: | |||
<source lang="papyrus"> | |||
Actor Player = Game.GetPlayer() | |||
ObjectReference[] kActors = Player.FindAllReferencesWithKeyword(ActorTypeNPC, 2048.0) | |||
int playerIndex = kActors.Find(Player as Actor) | |||
kActors.Remove(playerIndex) | |||
</source> | </source> | ||