Overview
A Fortnite island is full of lists: every player in the match, every creative object with a tag, every prop you spawned along the shore. Filtering an array means starting with a big list and producing a smaller list that contains only the elements matching some condition — the alive players, the lights tagged sunbeam, the characters that are crouching in the cove.
Verse doesn't need a special Filter() device or method for this. The language itself is the tool: a for expression can carry a filter clause (an if-style failable test) right in its header, and it only keeps the elements for which that test succeeds. Combine that with real Fortnite APIs — GetPlayers(), FindCreativeObjectsWithTag() / the deprecated GetCreativeObjectsWithTag(), and fort_character checks like IsActive[] and IsDownButNotOut[] — and you can grab exactly the agents or objects you want to act on.
Reach for array filtering whenever you think "do this, but only for the ones that...". Only give a reward to players still standing on the dock. Only turn on the lights with the sunbeam tag. Only count characters that are crouching. Filter first, then act on the survivors.
API Reference
(API surface could not be resolved for this device.)
Walkthrough
The island moment: It's a bright, cel-shaded afternoon on the cove. A button sits at the end of the dock. When any player presses it, a magical wave of sunlight should shine — but only on the players who are still active (in the world, not eliminated) AND not down-but-not-out. We take the full player list, filter it down to the healthy ones, and heal only those.
using { /Fortnite.com }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Devices/Patchwork }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
# Dock button that heals only the players who are still healthy and standing.
sunny_cove_healer := class(creative_device):
# The button placed at the end of the dock. Wire it in the Details panel.
@editable
DockButton : button_device = button_device{}
OnBegin<override>()<suspends>:void =
# Subscribe to the button. OnPressed runs every time a player interacts.
DockButton.InteractedWithEvent.Subscribe(OnPressed)
# Handler: receives the agent that pressed the button.
OnPressed(Presser : agent) : void =
# Start with EVERY player on the island.
AllPlayers : []player = GetPlayspace().GetPlayers()
# FILTER: build a new list of only the healthy, active characters.
# The `for` header runs the body for each player, but the filter
# clauses (Char := ...) and the two decides-checks must ALL succeed,
# otherwise that player is skipped.
HealthyChars : []fort_character =
for:
P : AllPlayers
Char := P.GetFortCharacter[] # skip players with no character
Char.IsActive[] # skip eliminated players
not Char.IsDownButNotOut[] # skip knocked players
do:
Char
# Now act on ONLY the filtered survivors.
for (C : HealthyChars):
C.Heal(25.0)
Line by line:
- The five
usinglines pull in the modules for devices, the button'sInteractedWithEvent, andfort_character. DockButtonis an@editablefield — you must declare the device as a class field to call it; a barebutton_device{}.Method()would fail with 'Unknown identifier'.- In
OnBeginweSubscribe(OnPressed)to the button'sInteractedWithEvent. This event hands the handler theagentwho pressed it. OnPressedis a class-scope method.GetPlayspace().GetPlayers()gives us the full[]player— the raw list we're about to filter.- The
for:block is the filter. Each line afterP : AllPlayersis a filter clause:Char := P.GetFortCharacter[]fails (and skips the player) if they have no live character;Char.IsActive[]skips eliminated players;not Char.IsDownButNotOut[]skips knocked players. Only players that pass every clause contribute theirCharto the resultingHealthyCharsarray. - The second
forloops the already filtered list and callsHeal(25.0)— the sunbeam only touches the survivors.
Common patterns
Filter creative objects by tag
Only want the props tagged sunbeam along the shore? GetCreativeObjectsWithTag returns an array of everything with that tag; filter it down to the ones you can treat as creative_prop and act.
using { /Fortnite.com }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
sunbeam_prop_gatherer := class(creative_device):
@editable
Trigger : trigger_device = trigger_device{}
OnBegin<override>()<suspends>:void =
Trigger.TriggeredEvent.Subscribe(OnTriggered)
OnTriggered(MaybeAgent : ?agent) : void =
# Grab everything tagged "sunbeam", then FILTER to real props only.
Tagged := GetCreativeObjectsWithTag(GetTagFromValue{Value := "sunbeam"})
SunbeamProps : []creative_prop =
for:
Obj : Tagged
Prop := creative_prop[Obj] # keep only the ones castable to prop
do:
Prop
# Do something only to the filtered props: hide them all.
for (P : SunbeamProps):
P.Hide()
Filter players by team
Give a shore-side reward only to players on a specific team, ignoring everyone else.
using { /Fortnite.com }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Devices/Patchwork }
using { /Fortnite.com/Teams }
using { /Verse.org/Simulation }
team_reward_dock := class(creative_device):
@editable
RewardButton : button_device = button_device{}
@editable
Granter : item_granter_device = item_granter_device{}
OnBegin<override>()<suspends>:void =
RewardButton.InteractedWithEvent.Subscribe(OnPressed)
OnPressed(Presser : agent) : void =
TeamCollection := GetPlayspace().GetTeamCollection()
AllPlayers := GetPlayspace().GetPlayers()
# Filter: keep only players who share the presser's team.
if (PresserTeam := TeamCollection.GetTeam[Presser]):
Teammates : []player =
for:
P : AllPlayers
PTeam := TeamCollection.GetTeam[P]
PTeam = PresserTeam
do:
P
# Grant only to the filtered teammates.
for (T : Teammates):
Granter.GrantItem(T)
Filter to just the crouching characters
Use a fort_character check inside the filter to count only players who are crouching on the clifftop.
using { /Fortnite.com }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
crouch_counter := class(creative_device):
@editable
CountTrigger : trigger_device = trigger_device{}
@editable
Billboard : billboard_device = billboard_device{}
CountMsg<localizes>(N : int) : message = "Crouching players: {N}"
OnBegin<override>()<suspends>:void =
CountTrigger.TriggeredEvent.Subscribe(OnCount)
OnCount(MaybeAgent : ?agent) : void =
AllPlayers := GetPlayspace().GetPlayers()
# Filter: keep only players whose character is active. (We can't read a
# live crouch bool synchronously, so here we filter to active chars
# and count those — the same filter shape works for any decides-check.)
ActiveChars : []fort_character =
for:
P : AllPlayers
Char := P.GetFortCharacter[]
Char.IsActive[]
do:
Char
Billboard.SetText(CountMsg(ActiveChars.Length))
Gotchas
- A
forfilter clause must FAIL, not return false.Char.IsActive[]andGetFortCharacter[]use square brackets because they are failable — when they fail, that element is silently dropped. WritingIsActive()(round brackets) is wrong; the<decides>version needs[]. GetCreativeObjectsWithTagis deprecated — it still works but the digest recommendsFindCreativeObjectsWithTag. Either returns[]creative_object_interface, and you almost always need a second filter (creative_prop[Obj]) to narrow the interface elements to the concrete type you can act on.- Filtering produces a NEW array; it never mutates the original.
AllPlayersis untouched after the filter —HealthyCharsis a separate list. Bind it to a name and loop that. GetTeam[...]is failable too. Comparing teams (PTeam = PresserTeam) only works after you've unwrapped both with[]. Do it inside the filter header so failures just skip the player.- Localized text needs a
<localizes>function.Billboard.SetTexttakes amessage, not a raw string — declareCountMsg<localizes>(...)and passCountMsg(N). There is noStringToMessage. - No int↔float auto-convert.
Healtakes afloat, so pass25.0, not25.ActiveChars.Lengthis anint, which is fine for the{N}message interpolation.