# Module `DCSController`

## Global(s)

Controller |

## Type `Controller`

Controller.Detection | Enum contains identifiers of surface types.
Controller:getDetectedTargets(detection) | Returns list of detected targets.
Controller:hasTask() | Returns true if the controller has a task.
Controller:isTargetDetected(target, detection) | Checks if the target is detected or not.
Controller:knowTarget(object, type, distance) | Know a target.
Controller:popTask() | Pops current (front) task from the queue and makes active next task in the queue (if exists).
Controller:pushTask(task) | Pushes the task to the front of the queue and makes the task active.
Controller:resetTask() | Resets current task of the controller.
Controller:setOnOff(value) | Enables and disables the controller.
Controller:setOption(optionId, optionValue) | Sets the option to the controller.
Controller:setTask(task) | Resets current task and then sets the task to the controller.

## Type `Controller.Detection`

Controller.Detection.DLINK |
Controller.Detection.IRST |
Controller.Detection.OPTIC |
Controller.Detection.RADAR |
Controller.Detection.RWR |
Controller.Detection.VISUAL |

## Type `DetectedTarget`

DetectedTarget.distance | Distance to the target is known
DetectedTarget.object | The target
DetectedTarget.type | The target type is known
DetectedTarget.visible | The target is visible

## Global(s)

#Controller Controller

## Type `DCSController`

## Type `Controller`

Controller is an object that performs A.I.-routines.

Other words controller is an instance of A.I.. Controller stores current main task, active enroute tasks and behavior options. Controller performs commands. Please, read DCS A-10C GUI Manual EN.pdf chapter "Task Planning for Unit Groups", page 91 to understand A.I. system of DCS:A-10C.

This class has 2 types of functions:

- Tasks
- Commands: Commands are instant actions those required zero time to perform. Commands may be used both for control unit/group behavior and control game mechanics.

### Field(s)

#Controller.Detection Controller.Detection

  Enum contains identifiers of surface types.

Controller:getDetectedTargets(detection)

  Returns list of detected targets.

  If one or more detection method is specified the function will return targets which were detected by at least one of these methods. If no detection methods are specified the function will return targets which were detected by any method.

  ### Parameter

  - `#Controller.Detection detection` : Controller.Detection detection1, Controller.Detection detection2, ... Controller.Detection detectionN

  ### Return value

  #list:

  # DetectedTarget> array of DetectedTarget

Controller:hasTask()

  Returns true if the controller has a task.

  ### Return value

  #boolean:

Controller:isTargetDetected(target, detection)

  Checks if the target is detected or not.

  If one or more detection method is specified the function will return true if the target is detected by at least one of these methods. If no detection methods are specified the function will return true if the target is detected by any method.

  ### Parameters

  - `Object#Object target` : Target to check

  - `#Controller.Detection detection` : Controller.Detection detection1, Controller.Detection detection2, ... Controller.Detection detectionN

  ### Return values

  1. #boolean: detected True if the target is detected.

  2. #boolean: visible Has effect only if detected is true. True if the target is visible now.

  3. #ModelTime: lastTime Has effect only if visible is false. Last time when target was seen.

  4. #boolean: type Has effect only if detected is true. True if the target type is known.

  5. #boolean: distance Has effect only if detected is true. True if the distance to the target is known.

  6. #Vec3: lastPos Has effect only if visible is false. Last position of the target when it was seen.

  7. #Vec3: lastVel Has effect only if visible is false. Last velocity of the target when it was seen.

Controller:knowTarget(object, type, distance)

  Know a target.

  ### Parameters

  - `Object#Object object` : The target.

  - `#boolean type` : Target type is known.

  - `#boolean distance` : Distance to target is known.

Controller:popTask()

  Pops current (front) task from the queue and makes active next task in the queue (if exists).

  If no more tasks in the queue the function works like function Controller.resetTask() function. Does nothing if the queue is empty.

Controller:pushTask(task)

  Pushes the task to the front of the queue and makes the task active.

  Further call of function Controller.setTask() function will stop current task, clear the queue and set the new task active. If the task queue is empty the function will work like function Controller.setTask() function.

  ### Parameter

  - `#Task task` :

Controller:resetTask()

  Resets current task of the controller.

Controller:setOnOff(value)

  Enables and disables the controller.

  Note: Now it works only for ground / naval groups!

  ### Parameter

  - `#boolean value` : Enable / Disable.

Controller:setOption(optionId, optionValue)

  Sets the option to the controller.

  Option is a pair of identifier and value. Behavior options are global parameters those affect controller behavior in all tasks it performs. Option identifiers and values are stored in table AI.Option in subtables Air, Ground and Naval.

  OptionId = AI.Option.Air.id or AI.Option.Ground.id or AI.Option.Naval.id OptionValue = AI.Option.Air.val[optionName] or AI.Option.Ground.val[optionName] or AI.Option.Naval.val[optionName]

  ### Parameters

  - `#OptionId optionId` : Option identifier.

  - `#OptionValue optionValue` : Value of the option.

Controller:setTask(task)

  Resets current task and then sets the task to the controller.

  Task is a table that contains task identifier and task parameters.

  ### Parameter

  - `#Task task` :

## Type `Controller.Detection`

Enum contains identifiers of surface types.

### Field(s)

Controller.Detection.DLINK

Controller.Detection.IRST

Controller.Detection.OPTIC

Controller.Detection.RADAR

Controller.Detection.RWR

Controller.Detection.VISUAL

## Type `DetectedTarget`

Detected target.

### Field(s)

#boolean DetectedTarget.distance

  Distance to the target is known

Object#Object DetectedTarget.object

  The target

#boolean DetectedTarget.type

  The target type is known

#boolean DetectedTarget.visible

  The target is visible

## Type `ModelTime`

## Type `OptionId`

## Type `OptionValue`

## Type `Task`

## Type `Vec3`

## Type `list`