Factorio API Docs

1.1.60 <>

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

add_member(unit)

Make a unit a member of this group.


set_command(command)

Give this group a command.


Give this group a distraction command.


Make this group autonomous.


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


Dissolve this group.


help()
string

All methods and properties that this object supports.


:: array[LuaEntity]
[R]

Members of this group.


[R]

Group position.


[R]

Whether this group is gathering, moving or attacking.


[R]

The force of this unit group.


[R]

The surface of this unit group.


:: uint
[R]

The group number for this unit group.


:: boolean
[R]

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


:: Command
[R]

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


:: Command
[R]

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


:: boolean
[R]

Is this object valid?


:: string
[R]

The class name of this object.

Methods

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

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.


help() → string

All methods and properties that this object supports.

Attributes

members :: array[LuaEntity] [Read]

Members of this group.


position :: MapPosition [Read]

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]

Whether this group is gathering, moving or attacking.


force :: LuaForce [Read]

The force of this unit group.


surface :: LuaSurface [Read]

The surface of this unit group.


group_number :: uint [Read]

The group number for this unit group.


is_script_driven :: boolean [Read]

Whether this unit group is controlled by a script or by the game engine. This can be changed using LuaUnitGroup::set_autonomous.


command :: Command [Read]

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


distraction_command :: Command [Read]

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


valid :: boolean [Read]

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.


object_name :: string [Read]

The class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.

|<

Classes

Events

Concepts

Defines

Builtin types

>|