BlueprintPseudocode guide

Loops

The engine's loop macros are written as the index loops they run, with the macro's name at the end of the line. Loop macros from your own macro libraries are a plain call with a block per output, as on Macros that wait.

For Each Loop

The loop body is indented. The Completed output runs after the loop, so it continues at the same level as for. The counter is i, then j, k, l in nested loops. The element is read as Enemies[i], since the loop reads its array again on every pass.

An array that comes out of a call is declared once as fn_X = () => ... and read as fn_X(): the call runs again on every pass. After the loop, the Index and Element pins hold what the last pass left in them; a read of them there is marked: /* breaks execution flow - after the loop: the last pass's index */.

event ClearWave()
    for (i = 0; i < Len(Enemies); i++)  // ForEachLoop
        Enemies[i].DestroyActor()

    ShowHint("Cleared")
Other loop forms
for (i = Len(Enemies) - 1; i >= 0; i--)  // ReverseForEachLoop
for (i = 0; i <= 9; i++)  // ForLoop
while (HasAmmo)
Nested
for (i = 0; i < Len(Teams); i++)  // ForEachLoop
    for (j = 0; j < Len(Teams[i].Members); j++)  // ForEachLoop
        Teams[i].Members[j].Revive()

Break

A wire into the Break pin of a "with Break" loop becomes break. When the wire comes from outside the loop body, for example from another event, the line names the loop by the line number of its for in the file you are reading: break // calls "break" on the loop at line 78.

    for (i = 0; i < Len(Enemies); i++)  // ForEachLoopWithBreak
        if (Enemies[i].IsBoss)
            break
        else
            Enemies[i].Stun()
Break from another event
event StopSearch()
    break  // calls "break" on the loop at line 78

An array wired into Target

An array wired into the Target pin of a call makes Blueprint call the function once for every element, then run what follows. It is written as that loop, with the call on the element. The node's outputs come from the last element's call.

Array<Actor*> OutActors = GameplayStatics::GetAllActorsOfClass(/Script/Engine.Actor)

for (i = 0; i < Len(OutActors); i++)  // array wired into Target
    OutActors[i].DestroyActor()

ShowHint("Cleared")