LuaUnitGroup

class LuaUnitGroup - sort
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.
members :: array of LuaEntity [R] Members of this group.
position :: Position [R] Group position.
state :: defines.group_state [R] Whether this group is gathering, moving or attacking.
force :: LuaForce [R] The force of this unit group.
surface :: LuaSurface [R] The surface of this unit group.
valid :: boolean [R] Is this object valid?
help() → string All methods, and properties that this object supports.

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.

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.group_state [Read-only]

Whether this group is gathering, moving or attacking.

force :: LuaForce [Read-only]

The force of this unit group.

surface :: LuaSurface [Read-only]

The surface of this unit group.