Controller#

Controller represents an AI routine that stores tasking, options, and behavior for either a Group or an individually-controllable Unit (planes and helicopters only). Different tasks/options/commands are available depending on the controlled group type (plane, helicopter, ground unit, or ship). Controller does not extend or inherit from any other class.

class Controller#
setTask(task)#

Assigns task as the controller’s main task, replacing any previous main task.

Parameters:

task (table) – An AI task table.

resetTask()#

Clears the controller’s main task and stops any current activity.

pushTask(task)#

Pushes task onto the controller’s task stack, to run before the current main task resumes.

Parameters:

task (table) – An AI task table.

popTask()#

Removes the top task from the controller’s task stack, resuming whatever task was running before it.

hasTask()#

Returns whether the controller currently has an active task.

Returns:

Whether a task is active.

Return type:

boolean

setCommand(command)#

Executes an immediate AI command (as opposed to a queued task).

Parameters:

command (table) – A command table.

setOption(optionId, optionValue)#

Sets an AI behavior option (e.g. Rules of Engagement, alarm state).

Parameters:
  • optionId (number) – Option identifier.

  • optionValue – New value for the option.

setOnOff(value)#

Turns the AI on (true) or off (false) for the controlled group/unit.

Parameters:

value (boolean) – Whether AI control should be enabled.

See also

trigger.action.setGroupAIOn() and trigger.action.setGroupAIOff(), convenience wrappers around this method.

setAltitude(altitude, keep, altType)#

Commands the controlled group to fly at the given altitude.

Parameters:
  • altitude (number) – Target altitude, in meters.

  • keep (boolean) – Optional; whether to maintain this altitude for the remainder of the route.

  • altType (string) – Optional altitude reference (e.g. AGL/ASL).

setSpeed(speed, keep)#

Commands the controlled group to fly at the given speed.

Parameters:
  • speed (number) – Target speed, in m/s.

  • keep (boolean) – Optional; whether to maintain this speed for the remainder of the route.

knowTarget(object, type, distance)#

Forces the AI to be aware of object as a known target, optionally marking how it was detected.

Parameters:
  • object (Object) – The target object.

  • type (boolean) – Optional; whether the target is known visually, by type, etc.

  • distance (boolean) – Optional; whether distance to the target is known.

isTargetDetected(object, detectionType, ...)#

Returns whether the controller currently detects object, and via which detection method(s).

Parameters:
  • object (Object) – The object to check.

  • detectionType (number) – One or more detection type flags (see Controller.Detection).

Returns:

Whether the target is detected, plus detection detail flags.

Return type:

boolean, ...

getDetectedTargets(...)#

Returns a table of targets currently detected by the controller, optionally filtered by detection type.

Parameters:

... – Optional detection type filters (see Controller.Detection).

Returns:

Detected target descriptor tables.

Return type:

table

Enumerators#

Controller.Detection identifies how a target was detected, for Controller.isTargetDetected() and Controller.getDetectedTargets():

Value

Meaning

Controller.Detection.VISUAL

Detected visually (1)

Controller.Detection.OPTIC

Detected via optic sensor (2)

Controller.Detection.RADAR

Detected via radar (4)

Controller.Detection.IRST

Detected via IRST (8)

Controller.Detection.RWR

Detected via RWR (16)

Controller.Detection.DLINK

Detected via datalink (32)

Footnotes#