Executes the given closure for every unit in this group, removing the units from the group as processed. Return true to continue iteration, false to stop.
📖 Read the detailed guide for hand-written examples and background.
public interface ForGroupCallback
Members:
callback(unit u)public interface ForGroupCallbackUntil
Return true to continue iteration, false to stop.
Members:
callback(unit u) returns boolpublic interface ForGroupCallbackD
Members:
callback(destructable d)public function forUnitsOfType(string unitname, ForGroupCallback c)
Executes the given closure for every unit of the given type. Remember that names of custom units are “custom_[typeId]”
public function forUnitsOfTypeCounted(string unitname, int count, ForGroupCallback c)
Executes the given closure for every unit of the given player. Cancels itself after count iterations
public function forUnitsOfPlayer(player p, ForGroupCallback c)
Executes the given closure for every unit of the given player
public function forUnitsAll(ForGroupCallback c)
Executes the given closure for every existing unit
public function forUnitsInRect(rect r, ForGroupCallback c)
Executes the given closure for every unit in the given rect
public function forUnitsInRectCounted(rect r, int count, ForGroupCallback c)
Executes the given closure for every unit in the given rect. Cancels itself after count iterations
public function forUnitsInRange(vec2 pos, real radius, ForGroupCallback c)
Executes the given closure for every unit in range of the given position
public function forUnitsInRange(vec2 pos, real radius, bool collisionSizeFiltering, ForGroupCallback c)
Executes the given closure for every unit in range of the given position With collisionSizeFiltering true it will take the units’ collision into account.
public function forUnitsInRangeCounted(vec2 pos, real radius, int count, ForGroupCallback c)
Executes the given closure for every unit in range of the given position Cancels itself after count iterations
public function forUnitsSelected(player p, ForGroupCallback c)
Executes the given closure for every unit selected by the given player
public function forNearestUnit(vec2 pos, real range, filterfunc filter, ForGroupCallback c)
Executes the given closure for the closest unit inside the given range of the given position, matching the provided filter. If there is no unit in range, the closure will be run with “null”
public function forUnitsOfTypeUntil(string unitname, ForGroupCallbackUntil c)
Executes the given closure for every unit of the given type. Return true to continue iteration, false to stop callback invocation.
public function forUnitsOfPlayerUntil(player p, ForGroupCallbackUntil c)
Executes the given closure for every unit of the given player. Return true to continue iteration, false to stop callback invocation.
public function forUnitsAllUntil(ForGroupCallbackUntil c)
Executes the given closure for every existing unit. Return true to continue iteration, false to stop callback invocation.
public function forUnitsInRectUntil(rect r, ForGroupCallbackUntil c)
Executes the given closure for every unit in the given rect. Return true to continue iteration, false to stop callback invocation.
public function forUnitsInRangeUntil(vec2 pos, real radius, ForGroupCallbackUntil c)
Executes the given closure for every unit in range of the given position. Return true to continue iteration, false to stop callback invocation.
public function forUnitsSelectedUntil(player p, ForGroupCallbackUntil c)
Executes the given closure for every unit selected by the given player. Return true to continue iteration, false to stop callback invocation.
public function forDestructablesInRange(vec2 pos, real range, ForGroupCallbackD cb)
Executes the given closure for all destructables in a rect that incompasses the circle with the range radius at the given position.
public function forDestructablesInRange(vec2 pos, real range, boolexpr filter, ForGroupCallbackD cb)
Executes the given closure for all destructables in a rect that incompasses the circle with the range radius at the given position.
public function forDestructablesInRect(rect r, ForGroupCallbackD cb)
Executes the given closure for all destructables in the given rect
public function forDestructablesInRect(rect r, boolexpr filter, ForGroupCallbackD cb)
Executes the given closure for all destructables in the given rect
public function forNearestDestructable(vec2 pos, real range, ForGroupCallbackD c)
Executes the given closure for the closes destructable in the given rect. If there is no destructable in range, the closure will be run with “null”
public function group.forEachFrom(ForGroupCallback cb)
Executes the given closure for every unit in this group, removing the units from the group as processed
public function group.forEachIn(ForGroupCallback cb)
Executes the given closure for every unit in this group, keeping all units in the group
public function group.forEachFromUntil(ForGroupCallbackUntil cb)
public function group.forEachInUntil(ForGroupCallbackUntil cb)
Executes the given closure for every unit in this group, keeping all units in the group. Return true to continue iteration, false to stop.