LuaUnitGroup

class LuaUnitGroup
add_member(unit) Make a unit a member of this group.
set_command(command) Give this group a command.
set_autonomous() Make this group autonomous.
start_moving() Make the group start moving even if some of its members haven't yet arrived.
destroy() Dissolve this group.
valid :: boolean [R] Is this object valid?
members :: array of LuaEntity [R] Members of this group.
position :: Position [R] Group position.
state :: defines.groupstate [R] Whether this group is gathering, moving or attacking.
force :: LuaForce [R] The force of this unit group.

A collection of units moving and attacking together. The engine creates autonomous unit groups to attack polluted areas. The script can create and control such groups as well. Groups can accept commands in the same manner as regular units.

add_member(unit)

Make a unit a member of this group. Has the same effect as giving a group_command with this group to the unit.

Parameters
unit :: LuaEntity
Note: The member must have the same force as the unit group.
set_command(command)

Give this group a command.

Parameters
command :: Command
set_autonomous()

Make this group autonomous. Autonomous groups will automatically attack polluted areas.

start_moving()

Make the group start moving even if some of its members haven't yet arrived.

destroy()

Dissolve this group. Its members won't be destroyed, they will be merely unlinked from this group.

valid :: boolean [Read-only]

Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.

members :: array of LuaEntity [Read-only]

Members of this group.

position :: Position [Read-only]

Group position. This can have different meanings depending on the group state. When the group is gathering, the position is the place of gathering. When the group is moving, the position is the expected position of its members along the path. When the group is attacking, it is the average position of its members.

state :: defines.groupstate [Read-only]

Whether this group is gathering, moving or attacking.

force :: LuaForce [Read-only]

The force of this unit group.