Design, review, and optimize Overwatch Workshop loop logic (Rule Loop, While, For) with safe Wait usage, bounded iteration, and server-load safeguards. Use when implementing loop behavior, diagnosing waitless loop crash risk, or choosing loop strategy for performance-sensitive rules.
Use this skill to design loop logic that is safe under multiplayer load and clear to maintain.
Focus on three loop forms:
loop, Loop If, Loop If Condition Is True, Loop If Condition Is False)While ... End)For Global Variable, For Player Variable)Use this workflow when you need to:
Patterns.Safety Guardrails and before shipping.Review ChecklistPrimary references:
Use this guide to select one loop type quickly.
| Situation | Preferred loop | Why |
|---|---|---|
| Repeat an entire rule over time until rule conditions change | Rule loop | Lowest ceremony and direct rule-level retry |
| Repeat a subset of actions while a runtime condition stays true | While loop | Keeps scoped action blocks together |
| Iterate over array items or numeric ranges with known bounds | For loop | Explicit index progression and finite termination |
Choose a different approach when:
When to use:
conditionsWhen not to use:
While)For)Minimum safe template:
rule("Pulse effect while Interact is held")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Is Button Held(Event Player, Button(Interact)) == True;
}
actions
{
Small Message(Event Player, Custom String("Pulse"));
Wait(0.200, Ignore Condition);
Loop If Condition Is True;
}
}
Safety floor:
Wait(...) before loop continuation0.016Related actions:
When to use:
When not to use:
Minimum safe template:
rule("Track movement trail while Ability 1 is held")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Is Button Held(Event Player, Button(Ability 1)) == True;
}
actions
{
Play Effect(All Players(All Teams), Ring Explosion, Color(Red), Position Of(Event Player), 8);
While(Is Button Held(Event Player, Button(Ability 1)));
Play Effect(All Players(All Teams), Ring Explosion, Color(White), Position Of(Event Player), 2);
Wait(0.016, Ignore Condition);
End;
Play Effect(All Players(All Teams), Ring Explosion, Color(Red), Position Of(Event Player), 8);
}
}
Safety floor:
Wait(...) inside WhileEndRelated actions:
When to use:
When not to use:
Minimum safe template:
variables
{
player:
0: index
1: targets
}
rule("Push enemies in radius")
{
event
{
Ongoing - Each Player;
All;
All;
}
actions
{
Event Player.targets = Players Within Radius(Event Player, 8, Opposite Team Of(Team Of(Event Player)), Surfaces);
For Player Variable(Event Player, index, 0, Count Of(Event Player.targets), 1);
Apply Impulse(
Event Player.targets[Event Player.index],
Direction Towards(Event Player, Event Player.targets[Event Player.index]),
15,
To World,
Cancel Contrary Motion
);
End;
}
}
Batching pattern for large loops:
For Global Variable(i, 0, Count Of(Global.bigArray), 1);
// expensive action
If(Modulo(Global.i, 20) == 0);
Wait(0.016, Ignore Condition);
End;
End;
Safety floor:
Range Stop is bounded and monotonic relative to StepRelated actions:
While block without Wait.All filters with late hero conditions.Wait.While is terminated by End.For loop has bounded stop and sane step direction.This skill is a structured rewrite derived from the Workshop.Codes Wiki.
Source references: