LuaUnitGroup

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.

class LuaUnitGroup - sort
add_member(unit) Make a unit a member of this group.
set_command(command) Give this group a command.
set_distraction_command(command) Give this group a distraction 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[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.
group_number :: uint [R] The group number for this unit group.
is_script_driven :: boolean [R] Whether this unit group is controlled by a script or by the game engine.
command :: Command [R] The command given to this group or nil is the group has no command.
distraction_command :: Command [R] The distraction command given to this group or nil is the group currently isn't distracted.
valid :: boolean [R] Is this object valid?
object_name :: string [R] The class name of this object.
help() → string All methods and properties that this object supports.
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_distraction_command(command)

Give this group a distraction command.

Parameters
command :: Command
set_autonomous()

Make this group autonomous. Autonomous groups will automatically attack polluted areas. Autonomous groups aren't considered to be script driven

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[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.

group_number :: uint [Read-only]

The group number for this unit group.

is_script_driven :: boolean [Read-only]

Whether this unit group is controlled by a script or by the game engine.

command :: Command [Read-only]

The command given to this group or nil is the group has no command.

distraction_command :: Command [Read-only]

The distraction command given to this group or nil is the group currently isn't distracted.